- Build, Run & Share Python code online using online-python's IDE for free. It's one of the quick, robust, powerful online compilers for python language. Don't worry about setting up python environment in your local. Now Run the python code in your favorite browser instantly. Getting started with this Python.
- $ python latesttutorial.py # Python Timer Functions: Three Ways to Monitor Your Code While many developers recognize Python as an effective programming language, pure Python programs may run slower than their counterparts in compiled languages like C, Rust, and Java.
- Online Python3 Compiler, Online Python3 Editor, Online Python3 IDE, Python3 Coding Online, Practice Python3 Online, Execute Python3 Online, Compile Python3 Online, Run Python3 Online, Online Python3 Interpreter, Execute Python-3 Online (Python v3.6.2).
It's hard to write programs or play with ideas on the go. Because PythonAnywhere runs on our servers and displays in your web browser, you can write Python applications from your iPad, phone, or smart TV just as easily as you can from your computer.
In this tutorial, learn how to execute Python program or code on Windows. Execute Python program on Command prompt or use Python IDLE GUI mode to run Python code.
Create your file in .py extension and execute using the step-step process given here. The steps are given here with pictures to learn in the easiest way.
How to Execute Python Program Using Command Prompt
If you want to create a Python file in .py extension and run. You can use the Windows command prompt to execute the Python code.
Here is the simple code of Python given in the Python file demo.py. It contains only single line code of Python which prints the text “Hello World!” on execution.
So, how you can execute the Python program using the command prompt. To see this, you have to first open the command prompt using the ‘window+r’ keyboard shortcut. Now, type the word ‘cmd’ to open the command prompt.
This opens the command prompt with the screen as given below. Change the directory location to the location where you have just saved your Python .py extension file.
You can use the cmd command ‘cd’ to change the directory location. Use ‘cd..’ to come out of directory and “cd” to come inside of the directory. Get the file location where you saved your Python file.
To execute the Python file, you have to use the keyword ‘Python’ followed by the file name with extension. See the example given in the screen above with the output of the file.
You can also execute the code directly in the interactive mode with the next section.
Interactive Mode to Execute Python Program
To execute the code directly in the interactive mode. You have to open the interactive mode. Press the window button and type the text “Python”. Click the “Python 3.7(32 bit) Desktop app” as given below to open the interactive mode of Python.
You can type the Python code directly in the Python interactive mode. Here, in the image below contains the print program of Python.
Press the enter button to execute the print code of Python. The output gives the text ‘”Hello World!” after you press the enter button.
Type any code of Python you want to execute and run directly on interactive mode.
However, you can also execute the Python program using the Python GUI. You have to use the below section and follow the examples with pictures.
Using IDLE(Python GUI) to Execute Python Program
Another useful method of executing the Python code. Use the Python IDLE GUI Shell to execute the Python program on Windows system.
Open the Python IDLE shell by pressing the window button of the keyboard. Type “Python” and click the “IDLE(Python 3.7 32 bit)” to open the Python shell.
Create a Python file with .py extension and open it with the Python shell. The file looks like the image given below.
It contains the simple Python code which prints the text “Hello World!”. In order to execute the Python code, you have to open the ‘run’ menu and press the ‘Run Module’ option.
or
You can also use the keyboard shortcut ‘F5’ to run the Python code file.
A new shell window will open which contains the output of the Python code. Create your own file and execute the Python code using this simple method using Python IDLE.
A Python IDLE mode can also execute the direct code.
To execute the direct code, you have to write the Python code directly on the Python IDLE shell. Here, a print function of Python prints the text “Hello World” on execution.
Python Code Runner
Hope, you like this tutorial of how to run Python program on windows.