Execute your program
Open a shell and navigate to where your program was saved using the cd (change directory) command.
Opening a Windows DOS shell
Do Start -> Run then type cmd.exe and click OK
The Windows directory that i created is C:\my_programs so i type cd \my_programs
C:\Documents and Settings\cpn>cd \my_programs C:\my_programs>
Now that you are in the right directory just type mileage.py
C:\my_programs>mileage.py Honda Accord mileage is 28.5714285714 miles per gallon Total trip cost is US$ 53.3092
Opening a Linux shell
My Linux directory is /home/cpn/my_programs
[cpn@dkt ~]$ cd /home/cpn/my_programs [cpn@dkt my_programs]$
Now type python mileage.py
[cpn@dkt my_programs]$ python mileage.py Honda Accord mileage is 28.5714285714 miles per gallon Total trip cost is US$ 53.3092
Windows versus Linux
To run a Python program in Windows just type the name of the program. It must have the .py extension.
To run it in Linux you type python followed by the name of the program. The program name does not need to have the .py extension.
There is a way to make Linux run a python program without typing python first.