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

Just wondering if this is a good way to do problem set 0 for the spring course: x = raw_input('Please enter your birth date: ') y = raw_input('Please enter your last name: ') print (x +' ' + y)

OpenStudy (lanhikari22):

hey if you don't mind me asking, what programming language is that?

OpenStudy (anonymous):

That looks good to me green but I don't think you need to put them in parenthesis. @LanHikari22 This is Python.

OpenStudy (e.mccormick):

What J.Soto is saying is mostly correct. You are mixing 2.x and 3.x type commands. `x = raw_input('Please enter your birth date: ')` is a 2.x command for getting input and needs parentisis. In Python 2, before 2.7.x, the print command was: `print "bla"` In Python 3 and the 2.7.x bridge, the print command was changed to a function and you use" `print ("bla")` However, pythin 2.7.x can actually use both: ``` Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> print "a" a >>> print ("a") a >>> ```

OpenStudy (rsmith6559):

FYI, print (x +' ' + y) can also be written: print x, y (Python2 syntax). The comma will give you a space between the variables. In a simple program like this it's not too important what the variables are named. As programs get bigger and more complex, useful variable names can make reading the code MUCH easier. For instance: birthDate = raw_input( " Please enter your birth date: " ) Never too early to start good habits!

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!