also i believe the first line can also be written as 'x = input('enter .......') instead of using x=int(raw_input('......') . use raw_input for string and just input for integer.
regards rajeev On Mon, Oct 6, 2008 at 3:30 PM, <[EMAIL PROTECTED]> wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Re: Tutor Digest, Vol 56, Issue 22 (Lie Ryan) > 2. Re: Tutor Digest, Vol 56, Issue 22 (Lie Ryan) > 3. Re: IF statements (Alan Gauld) > 4. Re: first call - newcomer (Alan Gauld) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 06 Oct 2008 12:46:49 +0700 > From: Lie Ryan <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Tutor Digest, Vol 56, Issue 22 > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain > > On Mon, 2008-10-06 at 05:32 +0200, [EMAIL PROTECTED] wrote: > > > > Message: 8 > > Date: Sun, 5 Oct 2008 20:27:39 -0700 > > From: Anthony Smith <[EMAIL PROTECTED]> > > Subject: [Tutor] first call - newcomer > > To: <tutor@python.org> > > Message-ID: <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > This is my first post - I will be brief... > > > > One: I have programmed before - but it has been DECADES...so just a > > few simple queries: > > > > 1. A brief (but complete) description regarding the use of script > > editor (I will be using > > Your script editor can be any plain text-editing tools, Notepad could > do. > > > command prompt in Windows), as: > > > > a. details about loading and saving programs (not in that > > order) and little > > specs about pathnames or other requirements (I will > > probably store all > > my little goodies in one folder or space). > > Pathnames is free, you can name your program anything your OS allows for > a file. A convention is to name the script ending with .py/.pyw > extension (command-line script/GUI script), although python doesn't > complain if it is not in those extension (in Windows, the extension is > associated with the interpreter). Calling a program from command line is > done like this: > > python filename.py > > > That should get me going ... a book and manual by my side should > > suffice for > > the rest - - - except for one thing: > > > 2. I have been unable to locate the gizmo in the literature to get > > ascii codes > > in python. In the old days, it was a list of 256 (or so) > > characters that > > represented all keyboard symbols (A equalled 36; B equalled 37; et > > cetera). > > To assign a value, you used "Let A$ = ASC (36)" where A$ was a > > variable > > and 36 was the ASCII value for 'A'. I believe the reverse of this > > process > > was PRINT VAL(A$) or something. I want to play with a program > > that will > > assign a number to a word (using a simple algorhythm that will give > > a > > specific number to every word). Other stuff is pretty easy to > > find with > > the book and on-line literature. I will need to get an ascii code > > out of > > a string (whose content is not known to the programmer, as > > raw_input). > > Then to assign, I will need the actual list with assigned numbers. > > a = ord('A') > b = chr(36) > > -- read on the help file: Built-in Functions > > > You will be giving me probably the only boost I will need! I will be > > available later on, > > if I want to take part in the ask/answer system here. > > > > ------------------------------ > > Message: 2 > Date: Mon, 06 Oct 2008 12:46:49 +0700 > From: Lie Ryan <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Tutor Digest, Vol 56, Issue 22 > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain > > On Mon, 2008-10-06 at 05:32 +0200, [EMAIL PROTECTED] wrote: > > > > Message: 8 > > Date: Sun, 5 Oct 2008 20:27:39 -0700 > > From: Anthony Smith <[EMAIL PROTECTED]> > > Subject: [Tutor] first call - newcomer > > To: <tutor@python.org> > > Message-ID: <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > This is my first post - I will be brief... > > > > One: I have programmed before - but it has been DECADES...so just a > > few simple queries: > > > > 1. A brief (but complete) description regarding the use of script > > editor (I will be using > > Your script editor can be any plain text-editing tools, Notepad could > do. > > > command prompt in Windows), as: > > > > a. details about loading and saving programs (not in that > > order) and little > > specs about pathnames or other requirements (I will > > probably store all > > my little goodies in one folder or space). > > Pathnames is free, you can name your program anything your OS allows for > a file. A convention is to name the script ending with .py/.pyw > extension (command-line script/GUI script), although python doesn't > complain if it is not in those extension (in Windows, the extension is > associated with the interpreter). Calling a program from command line is > done like this: > > python filename.py > > > That should get me going ... a book and manual by my side should > > suffice for > > the rest - - - except for one thing: > > > 2. I have been unable to locate the gizmo in the literature to get > > ascii codes > > in python. In the old days, it was a list of 256 (or so) > > characters that > > represented all keyboard symbols (A equalled 36; B equalled 37; et > > cetera). > > To assign a value, you used "Let A$ = ASC (36)" where A$ was a > > variable > > and 36 was the ASCII value for 'A'. I believe the reverse of this > > process > > was PRINT VAL(A$) or something. I want to play with a program > > that will > > assign a number to a word (using a simple algorhythm that will give > > a > > specific number to every word). Other stuff is pretty easy to > > find with > > the book and on-line literature. I will need to get an ascii code > > out of > > a string (whose content is not known to the programmer, as > > raw_input). > > Then to assign, I will need the actual list with assigned numbers. > > a = ord('A') > b = chr(36) > > -- read on the help file: Built-in Functions > > > You will be giving me probably the only boost I will need! I will be > > available later on, > > if I want to take part in the ask/answer system here. > > > > ------------------------------ > > Message: 3 > Date: Mon, 6 Oct 2008 09:31:04 +0100 > From: "Alan Gauld" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] IF statements > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=response > > "WM" <[EMAIL PROTECTED]> wrote > > > to IF. The code below was not written by me. It is a copy/paste > > job from the tutor. I do not have any idea what is going wrong. > > > >>> x = int(raw_input("Please enter an integer: ")) > > Please enter an integer: 42 > > >>> if x < 0: > > ... x = 0 > > ... print 'Negative changed to zero' > > ... elif x == 0: > > ... print 'Zero' > > ... elif x == 1: > > ... print 'Single' > > ... else: > > ... print 'More' > > ... > > More > > 12 > > SyntaxError: invalid syntax > > It looks as if you maybe cut more than you intended? > Also I'm not sure about the ... prompts. I don't have 2.6 yet > so maybe its an enhancement to IDLE but notmally IDLE > doesn't print ... prompts. Did you cut n paste them too? > If so that would confuse IDLE. > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > > > ------------------------------ > > Message: 4 > Date: Mon, 6 Oct 2008 09:38:14 +0100 > From: "Alan Gauld" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] first call - newcomer > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > > "Anthony Smith" <[EMAIL PROTECTED]> wrote > > > This is my first post - I will be brief... > > Hi, welcome to tutor :-) > > > 1. A brief (but complete) description regarding the use of script > > editor (I will be using command prompt in Windows), as: > > Brief and Complete don;t normally go together! > If you are using IDLE then Danny yoo's intro is a good place to start. > The IDLE section of the Python web site has a more detailed run > through oof the faciilities. > > a. details about loading and saving programs (not in that > order) and little > specs about pathnames or other requirements (I will > probably store all > my little goodies in one folder or space). > > As to paths: > > PATH should be set to the folder where the Python interpreters live > PYTHONPATH should be set to include the folder where your code lives > > > 2. I have been unable to locate the gizmo in the literature to get > > ascii codes > > in python. > > chr(n) is the function you need > ord(c) is the one in the opposite direction > > but... > > > was PRINT VAL(A$) or something. > > Python will generally figure out what you want to print without > explicit conversions, certainly fewer than you will be used to > from the early BASIC versions. > > > assign a number to a word (using a simple algorhythm that will > > give a > > specific number to every word). Other stuff is pretty easy to > > find with > > the book and on-line literature. I will need to get an ascii > > code out of > > a string (whose content is not known to the programmer, as > > raw_input). > > Then to assign, I will need the actual list with assigned > > numbers. > > OK, You lost me here. > Can you give an example of what the data would look like? > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > > > ------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > End of Tutor Digest, Vol 56, Issue 23 > ************************************* >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor