Writing python codes can be done in two ways:
- Writing Python code in a text editor and saving it with a .py extension. These file can then be executed.
- Writing Python code in a Python interactive shell. This method is useful for immediate testing of code with no stress of writing and saving the code in a file. This method is suitable only for testing purpose and for small codes.
Example 1: Printing Sum of two numbers in python using a text editor.
a = 2000 b = 4000 print a+b
Example 2: Printing Sum of two numbers in python using a Python interactive shell.