run python script on windows code example

Example 1: run python.py file

# save a file in text editor with .py
# open terminal, and change directories
# run the following command:
python3 file.py

Example 2: how to run python in terminal

#For Python 3:
$ python3 helloworld.py
#For Python 2:
$ python helloworld.py

Example 3: Windows 10 running python scripts from cmd

# move to the directory where the script is located and run it like so
cd (path to directory)
python name.py

Example 4: how to run python program

move to the directory where your program lies 
open cmd 
python first_script.py(your file name)

Example 5: how to execute a python script

C:\Python27\python.exe C:\Users\Username\Desktop\my_python_script.py

Tags: