Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 8 Online
OpenStudy (anonymous):

I've listened to the first lecture and I'm working on Problem Set 0. What I can't seem to figure out is how to take both raw_input's, assign them different values, and then print them. I know this is probably a really dumb question, but I appreciate any help.

OpenStudy (anonymous):

Post a sample of your code so we can look at it and explain/help with it. http://codepad.org/ (make sure to select Python) The solution involves 2 variables assigned to values that come from raw_input(). firstname = raw_input("Enter your first name:\n**") lastname = raw_input("Enter your last name:\n**") after that, you simply print out the strings stored in those variables. print lastname print firstname

OpenStudy (anonymous):

Maybe the real problem is I don't know how to start a Python file. Is there anything special I should be doing or do I just start with my first expression (firstname = raw_input...)? When I paste what I have into codepad I get an error on the first line ( http://codepad.org/YF29Y2W3) I tried to model 'my' code after the phrases you gave in case I did something wrong in my original. Thanks!

OpenStudy (anonymous):

did you open up a new page in idle? or did you just type everything right in?

OpenStudy (anonymous):

open up a new page in idle, type in your code (nothing wrong with it; EOF is raised because websites like codepad etc. can't emulate input), and Save as a .py file (type in a name like ps0.py). Then, press f5 or go to the Run menu and click Run Module

OpenStudy (anonymous):

I'm going to check in the morning. Thank you for your help!

OpenStudy (tonybaldwin):

Take a look at my solution, in python, bash, lisp, and tcl, here: http://baldwinsoftware.com/wiki/pmwiki.php?n=Main.MIT1 The python code is: #!/usr/bin/env python # Problem Set 0 # Name: Tony Baldwin # Collaborators: none # Time: 0:30 last = raw_input("Please enter your last name: ") first = raw_input("Please enter your first name: ") print(first + "\n" + last)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!