this was the program i wrote question1="Enter your first name" print(question1) firstname=raw_input() question2="Enter your second name" print(question2) secondname=raw_input() print(firstname) print(secondname) print(firstname,secondname) ... for example if the inputs are ron and hermione then the output is coming like ron hermione ('ron','hermione')..why is the third output coming with paranthesis and quotes.. i didnt understood that one...
print as a function instead of a statement is in py3, are you intentionally using py3? If not I'd switch to py2.7 for now. I'm not too familiar with py3 but changing the last line to: print(firstname + ' ' +secondname) Will get it to print normally
actually try the last line without parentheses and see what that does for you, you may be using py3 syntax on a py2.x interpreter
yeah thank you..Entering the last statement without parenthesis gave the actual output ...I dont know which python version i am using ..I am using ubuntu 10.10 and i am saving the program in a file and executing from the terminal...so which one would i be using?
I'm using ubuntu 10.1 also: python -V also when you start up idle it prints the version at the top.
hmm..its python 2.6.6
well it's python 2.x you'll want to be studying python 2.7 tutorials for now then. I'm finding o'rielly's: 'learning python' and 'programming python' to be quite you might want to see about finding those in a nice pdf( or I could donate them to you) it teaches py2.x/3.0 and notes the differences
Right now i am a beginner in python ..learning through the reading section in MIT course and the lectures..If you have any other links for important materials...It would be useful for me ....I went through all the languages (C,C++,java,Php) in my Bachelors but never learnt one properly and doesnt know to write a good program...thats why i started learning linux so that i may know the logical reasoning of writing programs...thanks in advance
I recommend checking out the Readings section. They link to a PDF there that you should read after each lecture.
How do I return while writing? I know it's a beginner question but this is my first day ever trying to program at all.
When i say return I mean go to the next line to write script.
Maybe I'm misunderstanding you but you push the enter key.
When I press the enter key it gives me the output For example: print 'Hello' then when I press enter Hello
Are you in python command line? In order to program in script you need run IDLE and python shell. In order to do that, you need to open notepad and then save it as a blank document with the extension .py. After its been saved you right click the document and click edit in IDLE.
So I can't write programs just using the Python shell? I write them in a document? How do I run a program that I have written? Sorry about all the questions. I'm still trying to understand the basics.
No I dont think so. I'm learning as well and just started, but i'm pretty sure you can't. Editing in IDLE is a pretty useful way of writing programs at least for me it is
Thank you. So each time I modify I have to go back, save, and then open?
I just tried that but I don't have notepad so i used pages and it won't let me save as .py. then, I tried copying and pasting onto IDLE but it said I had unsupported characters.
Open IDLE, and then go File -> New Window. That new window is your text editor. Then the original window is a python shell. You do your work in the text editor, then save to file, and run. Then you can interact with it in the python shell window.
Yay! My first program!
Congrats!
Join our real-time social learning platform and learn together with your friends!