[Tutor] pyhton (fwd)

alan.gauld@bt.com alan.gauld@bt.com
Fri, 28 Dec 2001 11:48:02 -0000


>> Python programs, we go from top-down, executing each statement 
>> in turn.  For example:
>> ###
>> print 1
>> print 2
>> print 3
>> ###
>> 
>> should print out:
>> 
>> ###
>>  1
>>  2
>>  3
>> ###

> i tried that but i just sead
> ###
> >>>1
> >>>print 2
> >>>2
> >>>print 3
> >>>3

Thats coz you are using pythons interactive mode.

If you type your program into a file using notepad say, 
or better still in IDLE use File|New menu item.

Then run that file using python from the DOS command line
(or using Ctrl-F5 in IDLE) it will act as Danny suggested.

To reiterate:

use notepad to create a file called prints.py containing:

print 1
print 2
print 3

Now start an MS DOS window and at the C:\> prompt type:

C:\> python prints.py

You should then see 

1
2
3

displayed as output.

OR in IDLE use File|Open to open a new window and 
type in the same 3 lines. Use File|SaveAs... to save 
the file as prints.py Now hit Ctrl-F5 and in the 
original IDLE window you will see the output:
1
2
3

As before.

HTH,

Alan G.