-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms
Before installing Python, check whether it is already installed on your system.
Open Command Prompt and type:
python --version
If installed, you will see something like:
Python 3.11.2
If not installed, it may show an error like 'python' is not recognized as an internal or external command
.
Open the Terminal and type the same command:
python3 --version
If Python 3 is installed, it will show the version.
Visit the official Python download page:
👉 https://www.python.org/downloads/
The site will automatically detect your operating system.
Click the Download Python 3.x.x button.
Run the downloaded .exe
file.
IMPORTANT: ✅ Check the box that says "Add Python to PATH" (This allows you to use Python from any folder).
Click "Install Now".
Wait for the setup to complete.
Click "Close" once done.
To verify, open Command Prompt and run:
python --version
Download the .pkg
installer from the official website.
Open it and follow the default installation steps.
After installation, open Terminal and type:
python3 --version
If you see a version like Python 3.12.0
, it’s installed correctly.
Most Linux distributions come with Python pre-installed. But to install the latest version:
sudo apt update
sudo apt install python3
Check the installation:
python3 --version
After installing Python, you also get pip (Python’s package manager).
Check Python:
python --version # or python3 --version
Check pip:
pip --version # or pip3 --version
Output should be like:
pip 23.0.1 from ... (python 3.11)
Now let's test Python by writing a simple program.
python
Then type:
print("Hello, Python!")
Output:
Hello, Python!
To exit, type:
exit()
Create a file named hello.py
with the following code:
print("Hello from a Python file!")
Run it:
python hello.py
If python
doesn’t work, try python3
.
Make sure “Add Python to PATH” was checked during Windows installation.
Use where python
(Windows) or which python3
(macOS/Linux) to locate Python.
Platform | Command to Run Python | Check Version |
---|---|---|
Windows | python |
python --version |
macOS | python3 |
python3 --version |
Linux | python3 |
python3 --version |
Q1. Print your name:
Expected: My name is CodePractice
Q2. Add two numbers and display:
Output: Sum: 15
Q3. Display installation success message:
Output: Python installed successfully!
Q4. Show today’s date using datetime
:
Output: Today’s date is: YYYY‑MM‑DD
Q5. Print three lines:
Welcome to Python
# Let's start coding
# Happy Learning!
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms