A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Are my answers to Ps0 correct?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Python 2.7 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> lastname = raw_input ("What is your last name? ") What is your last name? Doe >>> firstname = raw_input ("What is your first name? ") What is your first name? Noby >>> print ("Your name is ", firstname + lastname) ('Your name is ', 'NobyDoe') >>>

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I was just wondering if my answers were correct or should I have done them in a "command line" style where the user is asked along the way for there input?

  3. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Right - this is how I coded it when for the command line. print "Enter your last name:" answer1 = raw_input("** " ) print "Enter your first name:" answer2 = raw_input("** ") print answer2, answer1

  4. sandra
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    do you mind if i jump in?

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hi chris

  6. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hello!

  7. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    welcome

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks - i'm loving the MIT course and it's good to meet people here

  9. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    great! we think so too =). the community is very helpful. it's just nice to not have to learn such challenging material alone.

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i was looking for shadowfiend, it says he is in one of the study conversation but i cant seem to see him. maybe he's resting :-)

  11. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm right here actually :)

  12. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ah there he is

  13. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    haha lurker!

  14. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    that was weeirddd but cool

  15. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    lol I know what you mean.

  16. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i'm going to take a look around...

  17. Chris
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    sweet. nice meeting you.

  18. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi to every one. What is recommended book to learn python along with the course?

  19. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    how do you print in the next line?

  20. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hm. What do you mean by the next line?

  21. tim
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    HI Ja!

  22. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'd also like to contribute in this topic if you folks don't mind. I wanted to emulate something similar to the example on the pdf file. I wanted to get these results: Enter your last name: Doe Enter your first name: Jane Your name is: Jane Doe I wrote down the following for it: lastname = raw_input('Enter your last name: '); firstname = raw_input('Enter your first name: '); print ('Your name is: ' + firstname + ' ' + lastname)

  23. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    slight variation to ja9's work makes it more user friedly What is your last name? Doe What is your first name? John Hello John Doe print "What is your last name?"; lastname = raw_input(); print "What is your first name?"; firstname = raw_input(); print "Hello", firstname, lastname; having the print before the raw_input makes it jump to the next line. the raw_input() means the line where they type there is nothing on it.

  24. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Nice. Also, @commando1200, keep in mind that you don't need semicolons on the end in Python -- you can just change lines. You only need semicolons if you're going to put two distinct statements on the same line, which is generally frowned upon in Python anyway.

  25. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    This is what I did. I basically looked at the example in the problem set and just did that: last = raw_input("What is your last name?\n") first = raw_input("What is your fist name?\n") print first print last

  26. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm having trouble running my program. I wrote the code in IDLE and when I enter the last line (e.g. >>>print 'Hello', firstname, lastname) I get the correct response. But when I try to open the program in Python Launcher, i get an error saying invalid syntax. Can anyone offer any advice?

  27. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hm. Can you give us the full error message? It should have more details which will help in determining what is going on.

  28. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    kevins-macbook-pro-15:~ kevin$ cd '/Users/kevin/Desktop/' && '/usr/local/bin/pythonw' '/Users/kevin/Desktop/ps0try.py' && echo Exit status: $? && exit 1 File "/Users/kevin/Desktop/ps0try.py", line 1 Python 2.7.1 (r271:86882M, Nov 30 2010, 09:39:13) ^ SyntaxError: invalid syntax

  29. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    And what are the contents of the file?

  30. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    >>> print 'What is your last name? ' What is your last name? >>> lastname=raw_input() >>> print 'What is your first name? ' What is your first name? >>> firstname=raw_input() >>> print 'Hello', firstname, lastname Hello

  31. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ah ha! I figured it out. The >>> symbols shouldn't be in the saved file. So the new question is how do I save a file in IDLE so that the text file doesn't contain the greater than signs?

  32. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi guys, I just started on this class and I'm a bit overwhelmed by it. Anyway, can I just chip in and ask if my answer to PS0 is right? Or is the some other way I should write it in? answer1 = raw_input ('What is your last name?') answer2 = raw_input ('What is your first name?') print answer2, answer1

  33. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @k1e4v -- I believe IDLE has a File->New File or some such option that will let you open a new file in an editor. Then there will be a menu option that will let you run that file in the execution window where you've been typing until now. @alexisthetiny -- Looks good to me! Might want to put a space after the question mark on the raw_inputs so that the user isn't typing immediately next to the question mark, though.

  34. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @shadowfiend, thanks! =)

  35. abby
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

  36. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    No problem, glad to help!

  37. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    If you like to be grammatically correct, then for the last line, do the following: print "Your name is " + firstname + ' ' + lastname :)

  38. 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

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.