Running a Python Script
Running a Python Script
There are many different ways to run a Python script on your machine. In this tutorial, we will run a sample Python script in different ways on Windows operating system.
Using Interactive Interpreter
You can launch a Python interpreter by using the command prompt.
Launch command prompt.
Run >> cmd
Alternatively, you can launch Python from the Start menu as shown below.
Type python in the command prompt
/> python
Command Prompt
You can execute a Python script from the command line by specifying the script filename.
Add your code with your favorite editor like Notepad, Notepad++, Textpad etc. Save your code in a file with .py extension. The standard file extension of Python script file is .py
Run the script
Let say you have named the file as “program.py”, you can run the same by typing
/> python program.py
Eclipse IDE
You can run Python from an IDE( Integrated Development Environment) such as Eclipse.
Steps to run a script in Eclipse.
- Create a new project.
- Configure Python.
- Create a new file.
- And Python code to the file and save it.
- Right click and choose >> Run As >> Python Run
Python Tutorials
Python Tutorial on this website can be found at:
More information on Python is available at the official website:
- https://www.python.org