Hope that now you got familiar with the syntax of Python. Now let’s start programming in Python.
The procedure to save and run a Python program is as follows:
1. Open your favorite editor (notepad, WordPad or notepad++)
2. Write the program code
3. Save it as a file with the filename mentioned. I follow the convention of having all Python programs saved with the extension .py
4. Run the interpreter with command, python program.py
or
use IDLE to run the programs (here as an easiest way to do programming
First let us try in IDLE
For this, Open IDLE and then go to file>> New file
Now enter the codes for your program
i=5 print i i=i+1 print i s="this is my first prigram" print s
Now save it and Run by using the option in the menu (Run>> Run Module) or hit F5
You wil get something like the below picture
You can run Python progems in many ways
1. from your command prompt
Here you can just give " python <input_program_name .py> "
2. from terminal also " python <input_program_name .py> "
3. If you need to use the program variable just type: import_name_of_program_without_py
[ note that every program in python can also be considered as module]
4 When you are inside python, you can execute a program by
exec(open('filename.py').read())
5.