A plain text file containing Python code that is intended to be directly executed by the user is called script. As you know python is a high level programming language. A file containing a python script has an extension of ‘.py’.
There are many ways to run a Python script in Windows.
- Interactive mode
- Command line
In the Interactive Mode, you can run your script line by line in a sequence.
To enter an interactive mode, open Command Prompt on your Windows machine and type ‘
python’ and press
Now in this, you can run your python code line by line.
Using Command Line
To run a Python script stored in a ‘
.py’ file in the command line, we have to write ‘
python’ keyword before the file name in the command prompt.
Here, we are running a file named test.py in command line