Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

greenbastard

  • one year ago

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)

  • This Question is Open
  1. LanHikari22
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  2. J.Soto
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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 >>> ```

  4. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 2

    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!

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy