How to run a python file in terminal?
You have to install python before starting to work in it. There are multiple ways and different versions of python available today.
When you are done with the installing process of python you can run your program in the following two ways:-
- in interactive mode(also called Immediate mode)
- in script mode(in windows) or terminal(in mac and Linux)
Here we’ll see how to run python script or terminal?
First we have to write a program in a text editor and save it with .py extension. Then we have to open command prompt(cmd) and write the following syntax:-python file_name.py
Then our python script will be executed.
#demo example print(Hello, World!)
The name of my demo file is “hello.py”.
In mac and Linux, terminal is used by just search for terminal and type python and just use it. In this way we can use python script or terminal for python program.