Python Tutorials
- Python
- How to install Python?
- PIP
- How to Run Python Program
- Python Identifiers,Statement, Indentation and Comments
- Variable
- Data type
- Decision Making
- Python Loops
- Break,Continue, Pass
- Functions
- Predefine Functions
- Lambda Functions
- Variable Scope
- List
- Tuple
- Python Sets
- Python Dictionary
- Python String
- String Formating
- Input/Output
- File Handling (Input / Output)
- Iterators
- Python Modules
- Python Date
- Python JSON
- Classes and Objects
- Constructor
- Polymorphism
- Encapsulation
- inheritance
- Class or Static Variables in Python
- class method vs static method
- Abstraction
- Exception Handling
- MySql Python
- MySql Create Database
- MySql CRUD
- Django
How to run python program?
Thonny IDE
You can run your python program using Thonny IDE.
download Thonny IDE
DownloadFile name : index.php
Download Thonny IDE.
Run the installer to install Thonny on your computer.
Go to: File > New. Then save the file with .py extension. For example, hello.py, example.py, etc.
You can give any name to the file. However, the file name should end with .py
Write Python code in the file and save it.
Run Python on your computer
Running Python using Thonny IDE
Then Go to Run > Run current script or simply click F5 to run it.
Run Python Program in Visual Studio code editor
File name : index.php
install VS Code
install the Python extension for VS Code from the Visual Studio Marketplace.
The Python extension is named Python
create project folder python_programs
File name : test.py
open python_programs folder in your visual studio code editor.
select the New File button on the python_programs folder create a new file test.py in python_programs folder.
print("Hello mahi")
msg = "Hello World"
print(msg)
Save file test.py
Run Program
It's simple to run test.py with Python. Just click the Run Python File in Terminal play button in the top-right side of the editor.
File name : test.py
There are three other ways you can run Python code within VS Code:
1. Right-click anywhere in the editor window and select Run Python File in Terminal (which saves the file automatically):
2. Select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. This command is convenient for testing just a part of a file.
3. From the Command Palette (Ctrl+Shift+P), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
How to Run Python program on console
File name : test.py
C:\python_pro> python test.py
Run program
File name : test.py
C:\python_pro> python -u "c:\python_pro\test.py"
Run program
File name : test.py
C:\python_pro> python -u test.py
Write a program to test given no is even or odd.
File name : even_odd.py
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))
Run program
C:\python_pro> python -u even_odd.py