Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 7 Online
OpenStudy (anonymous):

for computer science can someone help me with the first problem set

OpenStudy (anonymous):

more specifically assigning the input of the users name to a variable

OpenStudy (anonymous):

yeah. See to assign anything to a variable we follow the following syntax: Variable_name=Value for example: firstName='Ben' Now here value (name) is not prior known to us, what we want to do is ask the user to input the name so that we can store it or assign it to the a variable. To input something from user we follow the following syntax: raw_input('Some text to display') for example: raw_input('Whats ur first name: ') this will print the text and wait for user to input thru keyboard. now since we want to store the input, we do the following: firstName=raw_input('Whats ur first name: ') now to print the firstName we simply do the follwing: print firstName hope this was helpful.

OpenStudy (anonymous):

Assigning basically has the form: myVariable = someExpression Where myVariable is the name of the variable you want to assign, and someExpression is an expression which will yield a value. In this case the expression you will use is a call to the function raw_input that will prompt the user for a string of text and return that text.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!