anonymous
  • anonymous
Are my answers to Ps0 correct?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
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') >>>
anonymous
  • anonymous
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?
chris
  • chris
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

Looking for something else?

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

More answers

sandra
  • sandra
do you mind if i jump in?
anonymous
  • anonymous
hi chris
chris
  • chris
hello!
chris
  • chris
welcome
anonymous
  • anonymous
thanks - i'm loving the MIT course and it's good to meet people here
chris
  • chris
great! we think so too =). the community is very helpful. it's just nice to not have to learn such challenging material alone.
anonymous
  • anonymous
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 :-)
shadowfiend
  • shadowfiend
I'm right here actually :)
anonymous
  • anonymous
ah there he is
chris
  • chris
haha lurker!
anonymous
  • anonymous
that was weeirddd but cool
chris
  • chris
lol I know what you mean.
anonymous
  • anonymous
i'm going to take a look around...
chris
  • chris
sweet. nice meeting you.
anonymous
  • anonymous
Hi to every one. What is recommended book to learn python along with the course?
anonymous
  • anonymous
how do you print in the next line?
shadowfiend
  • shadowfiend
Hm. What do you mean by the next line?
tim
  • tim
HI Ja!
anonymous
  • anonymous
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)
anonymous
  • anonymous
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.
shadowfiend
  • shadowfiend
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.
anonymous
  • anonymous
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
anonymous
  • anonymous
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?
shadowfiend
  • shadowfiend
Hm. Can you give us the full error message? It should have more details which will help in determining what is going on.
anonymous
  • anonymous
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
shadowfiend
  • shadowfiend
And what are the contents of the file?
anonymous
  • anonymous
>>> 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
anonymous
  • anonymous
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?
anonymous
  • anonymous
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
shadowfiend
  • shadowfiend
@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.
anonymous
  • anonymous
@shadowfiend, thanks! =)
abby
  • abby
shadowfiend
  • shadowfiend
No problem, glad to help!
anonymous
  • anonymous
If you like to be grammatically correct, then for the last line, do the following: print "Your name is " + firstname + ' ' + lastname :)

Looking for something else?

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