In this tutorial, we will learn how to run a Python program from the command line. We will also learn how to use the python interpreter and write a simple Python program.
The run python script from python shell is a command-line tool that allows users to run their first Python program.
What exactly is Python?
Python is a high-level programming language that is used to create web applications. It is open-source and object-oriented. It’s one of the most basic scripting languages, with a straightforward syntax and easy reading. Python applications outperform other web application development languages in terms of productivity and performance.
You’ll learn how to execute your first Python program from the command line on Windows in this post.
To run a Python application, you’ll need the following components.
To run a Python application, you’ll need the following two main components.
- Python: On your computer, download and install the most recent version of Python.
- Write your Python program and save it in a file with the extension.py.
What is the python program file extension?
Files with the.py suffix are used to store Python applications.
What is the best way to make a.py file?
You may make a.py file by storing any file that ends in.py. The procedures for saving your Python program as a.py file are as follows.
Step 1: Write your Python program in Notepad or another text editor.
Step 2: Open Notepad and choose the Save As option from the File menu.
Step 3: Select All Files (*.*) in the ‘Save as type‘ box, and enter the name of the file with the.py extension in the ‘File name‘ box, as shown below.
Step 4: Select Save. At the specified directory, a program file with the.py suffix is generated.
Note: You may also create your Python program in a text file and then change the file’s extension to “.py.”
To execute your first Python application, follow these steps:
Create a program file in the first step.
Write the following basic Python program and save it in a.py file as described in the previous step. We’ve stored the code in the First Program.py file for this example.
Write the sample code below in Notepad or any other text editor and save the file with the.py extension as an example. We’re going to save it as First Program.py.
# Welcome to TechSupportWhale! print(“Welcome to TechSupportWhale!”)
The first line in this code indicates a commented text that begins with #. Like any other language, the commented lines are skipped during code execution. In Python programming, this is known as a single-line comment. In Python Programming, learn how to remark a block of code or a multi-line comment.
Step 2: Put the program into action.
- Open the Command Prompt by typing cmd into the Windows search box.
- Type cd and then the path to the folder containing your application file. It will update the directory of the command prompt to the desired path.
- To run the application, use the python command below.
first program.py in python
The command prompt displays the result “Welcome to TechSupportWhale!”
If you receive the message “‘python’ is not recognized as an internal or external command, operable program, or batch file,” it means “python is not recognized as an internal or external command, operable program, or batch file.” To fix the problem, go to the python is not recognized as an internal and external command article.
I hope this post made it easier for you to run your first Python program from the command line. If you run into any problems when running your Python program, please let us know in the comments area and we’ll do our best to help you out.
Good luck with your studies!!!
- run python in terminal windows
- run python script from command line
- run python script from command line linux
- how to run python script windows 10
- how to save python program in command prompt