To open the Python Shell on Windows, open the command prompt, write python
and press enter.
As you can see, a Python Prompt comprising of three Greater Than symbols (>>>) appears.
Now, you can enter a single statement and get the result. For example, enter a simple expression like 3 + 2
, press enter and it will display the result in the next line, as shown below.
Execute Python Script
As you have seen above, Python Shell executes a single statement.
To execute multiple statements, create a Python file with extension .py
, and write Python scripts (multiple statements).
For example, enter the following statement in a text editor such as Notepad.
print ("This is Python Script.")
print ("Welcome to Python Tutorial by http://python-tutorials.in")
Save it as myPythonScript.py
, navigate command prompt to the folder where you have saved this file and execute the python myPythonScript.py
command, as shown below.
Thus, you can execute Python expressions and commands using Python Shell. We will be using Python Shell to demo Python features through out these tutorials.