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

can someone help me verify that this is the right/ or one of the right ways to code the "questions/answers" for problem set 0 this would be a great help to me. >>> red = "Enter your date of birth:" >>> blue = "02/17/92" >>> yellow = "Enter your last name:" >>> purple = "Franks" >>> print (red) Enter your date of birth: >>> print (blue) 02/17/92 >>> print (yellow) Enter your last name: >>> print (purple) Franks >>> print (purple, blue) ('Franks', '02/17/92')

OpenStudy (e.mccormick):

Well, you would generally make a .py file and have it take in the name, etc. using raw input. Then print hte result.

OpenStudy (anonymous):

so this is technically right but not in the right format?

OpenStudy (e.mccormick):

Well, you are not using the input function.

OpenStudy (e.mccormick):

Things like: ``` firstname = raw_input('What is your first name?') print (firstname) ```

OpenStudy (anonymous):

and then to answer that question i would write? name = raw_input('Cory') print (name)

OpenStudy (e.mccormick):

raw_input prints out the prompt: varaiable = raw_input('Prompt') It then assigns whatever the person types in to the variable.

OpenStudy (e.mccormick):

Input methods are a way to make a program reusable. When you hard code in the name, what happens if the next person to use the program has a different name? By asking for the name, you let anyone use the program.

OpenStudy (anonymous):

soo Cory = raw_input('Enter your first name') would produce my name if i say print (Enter your first name) or no? P.s about all the repetitive questions, I'm having a hard time with the whole x = raw_input() part and getting the results i need

OpenStudy (anonymous):

oh ok i think i might understand let me work this out and ill repost new code or com back here

OpenStudy (anonymous):

the only part i don't under stand how to do is get it to print both answers on the same line for that last part

OpenStudy (e.mccormick):

Try this and see what you get, then think about it: print ('a' + 'b')

OpenStudy (anonymous):

so heres what i have now using raw input birthday = raw_input('Enter your date of birth:') Enter your date of birth:02/17/92 >>> lastname = raw_input('Enter your last name:') Enter your last name:Franks >>> print (lastname + birthday) Franks02/17/92 grants theres no space between my last name and birthday because i can't figure out how to get one without it ending up like this >>> print (lastname, birthday) ('Franks', '02/17/92')

OpenStudy (e.mccormick):

Just add the space. print (lastname + ' ' + birthday)

OpenStudy (anonymous):

oh really i didn't know you could do that, thanks for being very patient with me man

OpenStudy (e.mccormick):

It is now we learn. Trial and error. =)

OpenStudy (anonymous):

yeah true

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!