Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Run python program in terminal

Python programming is free and easy to learn. Before you start doing Python programming, you need to install a Python interpreter. The latest version of python is python 3.8.1(3.X), Which you need to download from python.org and install it.

Install Python

Most of the python tutorials assume that the user knows how to write and run the program. Once you downloaded the python installation file, follow the below steps. Whether you are a Windows user or a Mac user, you can follow the same steps.

Step 1: Download Python 
Download Python

Step 2: Install Python on Windows/Mac
Make sure you check the option "Add Python 3.8 to PATH", Later in this article we will showcase the reason behind it.
Install Python on Windows/Mac

Step 3: Python installation setup progress
Python installation setup progress

Step 4: Python is successfully installed, click on close.


How to run python program in terminal

Here I will teach you ways to run python program in terminal. Mac users can follow the same steps to run python program in shell. We will see 3 ways to run the python program.

1. How to tun python program in cmd (Windows command prompt)

As mentioned earlier in this article, while installing python we have checked the option "Add Python to PATH". Here when you use the windows command prompt, you first need to invoke the python interpreter. For that, write simple command "python" and hit the enter button.

As you can see in the above image, it starts python interpreter and you can see 3 >>> sign. After that, you can write a simple Hello World program using the print() function.

2. How to run python program using python command line

As soon as you start the python command line, it automatically starts a python interpreter. You can directly write a simple Hello World program using the print() function.

3. How to run python script from python command line

Open notepad and write a program, save it as "Helloworld.py". Now open windows command prompt, go to the path "cd Desktop" where you have saved the file. After that write command "python Helloword.py" and press enter to run.



This post first appeared on Ask For Program, please read the originial post: here

Share the post

Run python program in terminal

×

Subscribe to Ask For Program

Get updates delivered right to your inbox!

Thank you for your subscription

×