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

Can anyone help me understand unit 1's problem set 1? the problem set with the whole "enter your bdate of brith, enter your last name?" thanks!

OpenStudy (anonymous):

the prob set is called: Introduction to Python and IDLE

OpenStudy (anonymous):

The solution has been included, have you compared your code with that? What precisely are you having an issue understanding?

OpenStudy (anonymous):

I could not find a solution for this one to compare against but was able to create working code. What is the problem you're having with this set?

OpenStudy (anonymous):

I do not understand anything to do with this set. Everytime I type in anything in IDLE, all I get is this invalid syntax message. I have to type in the question what is your birthdate, and then what is your last name. I typed in both and received the invalid syntax msg. and when I typed in numbers, same thing.

OpenStudy (anonymous):

the first thing to do would be to open a file to put your code in. you don't want to type everything in the shell :) have you watched the lecture video 1 and 2? there it is explained how to use the raw_input thing

OpenStudy (anonymous):

yea i watched the videos and i'm still confuded haha

OpenStudy (anonymous):

could you post your code?

OpenStudy (anonymous):

ok, this is all I'm typing in: raw_input "what is your date of birth" raw_input "what is your last name"

OpenStudy (anonymous):

and i get invalid syntax error with that but im not sure what else to do

OpenStudy (anonymous):

i understand nothing of this problem set, unfortunately...

OpenStudy (anonymous):

you should type something like this x = float(raw_input('Enter your date of birth: ')) y = raw_input('Enter your last name: ') print y,x

OpenStudy (anonymous):

sorry, without the float its right

OpenStudy (anonymous):

thanks so much!

OpenStudy (anonymous):

it worked finally haha!

OpenStudy (rsmith6559):

raw_input() is a function. Functions, in most languages, are called with the function name and arguments/parameters inside of parentheses. In this case, the prompt that you want displayed is the argument. Functions can return a value. In this case, what the user types in is returned as a string. Programming languages are formal languages. In simple terms, a formal language has one way that it works, and everything else is rejected, syntax errors.

OpenStudy (anonymous):

I am having some problems getting the output from this problem to display properly. I get the birth date and last name to display, but i can't figure out how to get a space between those two values. Here is my code: question = "What is your birthdate?" print (question) answer = raw_input () question1 = "What is your last name?" print (question1) answer1 = raw_input () print (answer1 + answer) Thanks!

OpenStudy (rsmith6559):

The two strings, answer1 and answer are "added" together. Do either of them have a space? Probably not. You could also "add" (concatenate) a space between those two strings. print( answer1 + ' ' + answer )

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!