[Tutor] 4 begginers questions ... (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sat Nov 8 21:00:09 EST 2003


Hi David,

I will forward this message to the Python-Tutor mailing list.


Instead of emailing Alan or the 'tutor-owner at python.org' address directly,
you may want to send your messages on the Tutor mailing list.  There are a
lot of experts and learners on the list, so it's a great place to ask
questions.

To subscribe to Python-Tutor, see:

    http://mail.python.org/mailman/listinfo/tutor

Good luck to you!

---------- Forwarded message ----------
Date: Sun, 9 Nov 2003 00:59:57 +0100
From: Tadey <tayiper at volja.net>
To: tutor-owner at python.org
Subject: 4 begginers questions ...


Hello ...

I am newbie at programming, and though I have allready send this mail to Alan Gauld (and also to Kirby Urner - the webmaster on python.org - and got his answer), I think there would be good to ask this "begginer" questions also here:



1.) I was puting in some wrong values, and python start to calculating endlessly, so I would like to know, if it is possible,  how to force python to stop executing my instructions in that cases (without quiting program) ??


************************************************************************


2.) And second, after error message, is python continuing from last line, or do I need to retype all from the begging of current program (I suppose exept variables, which were set previous)


************************************************************************


3.) In your (Alan Gauld) tutorial in part "Conversing with the user" it says:


>>> print raw_input("Type something: ")

As you see raw_input simply displays the given prompt and captures whatever the user types in response. Print then displays that response. We could instead assign it to a variable:

resp = raw_input("What's your name? ")
print "Hi, %s, nice to meet you" % resp


So, the question is (though not so important, I couldn't live without knowing the answer):
Answer on that promt is displayed right after "prompt" line, so what do you mean with ... "Print then displays that response." ...


... it looks like that, in all cases it displays promt:

>>> raw_input("What's your name?")
What's your name?  David     #  when I hit return here after David it display response automaticly ...
'David'


>>> resp = raw_input("What's your name?")
What's your name?  David     #  right after this line wich display promt and response to that promt - so what is then with ...
'David'


>>> print raw_input("What's your name?")
What's your name?  David     #  "Print then displays that response." (it's impossible to print response afterwards)
'David'


 ... so actually there is no need (and impossible though) to use print command again to display that response, (the response is displayed automaticly, right after second "promt/response" line) so response is "captured" only if we set the answer to variable (like in second case) ...


************************************************************************


4.) Different between :

>>> a = "dav"
>>> print a    #  type print a and hit return ...
'dav'             #  dav is displayed inside ' ' sign

>>> a = "dav"
>>> a          #  type a and hit return in this case ...
dav              #  dav is displayed without ' ' signs




Thanks for this great tutorial, please don't be mad, I am begginer ...


David from Slovenija




More information about the Tutor mailing list