Run Python Program [ 2024 ]
Run Python Program
This tutorial will explore various ways to run a Python program. The methods used vary depending on the environment and setup.
Different ways to execute
There are multiple ways to run a Python program. There are as follows:
- Using command-line
- Using Python IDLE
- Using an IDE like PyCharm
- Using Google Colab
Command Line
Open a command prompt window.
Navigate to the directory where your Python script is located using the cd command.
To Run Python Program, type the following command:
/> python program.py
or
For Python 3
/> python3 program.py
For example, to run the file hello.py, use the following command:
python hello.py
or
python3 hello.py
If the python or python3 commands are not recognized, you might need to add Python to your system’s PATH environment variable.
Python IDLE
Follow these instructions to Run a Python program with the Python IDLE. The steps to run a Python program using IDLE are as follows:
Click on the Start Menu.
Search for IDLE and click on the Python IDLE start menu entry.
To open a new file. Click File -> New File
or
Press the keyboard shortcut: Crtl + N
After you have written your code. Make sure to save it. File -> Save
To run the program, click on Run -> Run Module or press F5
Google Colab
Create a Colab Notebook.
Click on the Run play button
or
Choose the run options from the Runtime menu.
—
Python Tutorials
Python Tutorial on this website can be found at:
More information on Python is available at the official website: