0% found this document useful (0 votes)
15 views1 page

How To Run Python Scripts

Ntg

Uploaded by

tashirongkup27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

How To Run Python Scripts

Ntg

Uploaded by

tashirongkup27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

How to Run a Python Script

Python scripts are Python code files saved with a .py extension. You can run these
files on any device if it has Python installed on it. They are very versatile programs
and can perform a variety of tasks like data analysis, web development, etc.
You might get these Python scripts if you are a beginner in Python so in this
discussion, we will explore various techniques for executing a Python script.
What is Python Script?
Python is a well-known high-level programming language. The Python script is a file
containing Python-written code. The file containing Python script has the extension
‘.py’ or can also have the extension ‘.pyw’ if it is being run on a Windows 10
machine.
To run a Python script, we need a Python interpreter installed on the device. In this
article, we will learn how to run a Python script.
How to Run a Python Script?
Let’s go through the basic steps and understand how a script works.
Here is a simple code to print ‘Hello World!’.
 Python3

print('Hello World!')

To Execute this program, first we have to save it with the ‘.py’ extension. Then we
can execute this file with the help of the terminal.
Here, the print() function is to print out any text written within the parenthesis. We
can write the text that we want to be printed using either a single quote as shown in
the above script or a double quote.
If you are coming from any other language then you will also notice that there is no
semicolon at the end of the statement as, with Python, you do not need to specify a
semicolon at the end of the line. And also we don’t need to include or import any files
to run a simple Python script.
There are various ways to run a script in Python but before going toward the different
ways to run a Python script, we first have to check whether a Python interpreter is
installed on the system or not. So in Windows, open ‘cmd’ (Command Prompt) and
type the following command.
python -V
This command will give the version number of the Python interpreter installed or will
display an error if otherwise.

You might also like