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

for problem set 0, i am typing "birthdate = raw_input('Enter your birthdate: ')" and then pressing enter and typing my birthdate and then pressing enter and typing "name = raw_input('Enter your name: ')" and then pressing enter and typing my name and then pressing enter and typing "print(name + birthdate)" in order to complete the assignment. is there a way to write the program all before so that, when run, it asks for birthdate, then the user types it, then it asks for a name, then the user types it, and then it prints out the name and the date?

OpenStudy (anonymous):

try this and let me know if it works! birthdate = raw_input('Enter your birthdate: ') if str() in birthdate: inputa= birthdate name=raw_input('Please, write your name: ') if str() in name: inputb= name print" Your name is", inputb, " and your birthdate is", inputa, "." since you used raw_input i figured u r running Python 2.x. u might want to experiment with the type handling in the code because in its current state i think it is crash-prone

OpenStudy (anonymous):

i think i might be typing this in the wrong spot... in which window am i supposed to type the code? in the IDLE window? i'm a bit confused as a beginner, thanks for your help!

OpenStudy (anonymous):

if u want to use this piece again click on File>New while on the IDLE window. then type in exactly as u see it. pay close attention to the white spaces(indentations).or copy and paste it. but if you just want the interactive mode where you type in and get response there and then, type the code when you see the >>> prompt. feel free to ask me if anything isn't clear!

OpenStudy (anonymous):

thank you so much! it makes sense now, i was typing after the >>> and that was confusing me. you're the best!

OpenStudy (anonymous):

OK! am glad it worked out well for u!

OpenStudy (anonymous):

I did it this way in homework_1.py and it ran fine. I hope that was what was wanted ;-) print ("********** Exercise 1.5 **********") firstName = raw_input('Enter your first name: ') lastName = raw_input('Enter your last name: ') print 'Enter your date of birth: ' month = raw_input('Month? ') day = raw_input('Day? ') year = raw_input('Year? ') print 'Chuck Norris was born on March 10, 1940.'

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!