OpenStudy (anonymous):

Are my answers to Ps0 correct?

6 years ago
OpenStudy (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') >>>

6 years ago
OpenStudy (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?

6 years ago
OpenStudy (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

6 years ago
OpenStudy (sandra):

do you mind if i jump in?

6 years ago
OpenStudy (anonymous):

hi chris

6 years ago
OpenStudy (chris):

hello!

6 years ago
OpenStudy (chris):

welcome

6 years ago
OpenStudy (anonymous):

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

6 years ago
OpenStudy (chris):

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

6 years ago
OpenStudy (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 :-)

6 years ago
OpenStudy (shadowfiend):

I'm right here actually :)

6 years ago
OpenStudy (anonymous):

ah there he is

6 years ago
OpenStudy (chris):

haha lurker!

6 years ago
OpenStudy (anonymous):

that was weeirddd but cool

6 years ago
OpenStudy (chris):

lol I know what you mean.

6 years ago
OpenStudy (anonymous):

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

6 years ago
OpenStudy (chris):

sweet. nice meeting you.

6 years ago
OpenStudy (anonymous):

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

6 years ago
OpenStudy (anonymous):

how do you print in the next line?

6 years ago
OpenStudy (shadowfiend):

Hm. What do you mean by the next line?

6 years ago
OpenStudy (tim):

HI Ja!

6 years ago
OpenStudy (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)

6 years ago
OpenStudy (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.

6 years ago
OpenStudy (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.

6 years ago
OpenStudy (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

6 years ago
OpenStudy (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?

6 years ago
OpenStudy (shadowfiend):

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

6 years ago
OpenStudy (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

6 years ago
OpenStudy (shadowfiend):

And what are the contents of the file?

6 years ago
OpenStudy (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

6 years ago
OpenStudy (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?

6 years ago
OpenStudy (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

6 years ago
OpenStudy (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.

6 years ago
OpenStudy (anonymous):

@shadowfiend, thanks! =)

6 years ago
OpenStudy (abby):

6 years ago
OpenStudy (shadowfiend):

No problem, glad to help!

6 years ago
OpenStudy (anonymous):

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

6 years ago
Similar Questions: