Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ashleewest

Hi everyone - I am doing the first problem set (#0) and I have almost figured it out and got it working but when I run the module it asks the two questions twice before it outputs your name and d.o.b together. Can anyone help?

  • one year ago
  • one year ago

  • This Question is Closed
  1. ashleewest
    Best Response
    You've already chosen the best response.
    Medals 0

    actually never mind - i figured it out! But it would be great if someone could have a look at my final source code to see if it is in fact correct or if there is another way you could do it. This is what I ended up with: dob = raw_input('What is your date of birth? ') name = raw_input('What is your last name? ') print(name + dob)

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

    this code is absolutely right as you are taking name and dob as strings and then adding them up

    • one year ago
  3. bwCA
    Best Response
    You've already chosen the best response.
    Medals 1

    is there a space between name and dob? is that what you intended? another way might be; print name, dob

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

    An easier to understand version of the space could be a literal concatenation: print name + " " + dob

    • one year ago
  5. dkoobs
    Best Response
    You've already chosen the best response.
    Medals 0

    I think your code is right for python 3, but not for version 27. Does it matter which one we use for this course?

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

    His code is good for v2.x. V3 uses input() instead of raw_input().

    • one year ago
  7. ashleewest
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks for your input guys! I didn't intend for there to be aspace but I wasn't sure if there needed to be a space either side of the '+' sign but I wil keep your comments in mind for when I do want a space :) Thanks everyone you have been super helpful.

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

    The space on the side of the plus sign is an optional matter of syntax. When you're concatenating strings, you get exactly what you specify: print "Hello" + "World" # is probably wrong print "Hello " + "World" # is probably right

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.