Step 1: Install Python
Windows
- Download Python from python.org
- Run the installer and select Add Python to PATH
- Verify installation by opening the command prompt and typing:
python --version
Mac & Linux
Python is pre-installed on most systems. To check:
python3 --version
If not installed, use:
sudo apt install python3 # Ubuntu/Debian brew install python # macOS
Step 2: Run Your First Python Program
Using the Python Shell
Open a terminal or command prompt and type:
python
Then, enter:
print("Hello, World!")
Using a Python Script
- Create a new file hello.py
- Add this code:
print("Hello, Python!")
- Run the script:
python hello.py
Step 3: Python Basics
Before diving deep, learn the basics:
1. Variables & Data Types
name = "Alice" # String age = 25 # Integer height = 5.6 # Float is_student = True # Boolean
2. Conditional Statements
age = 18 if age >= 18: print("You are an adult.") else: print("You are a minor.")
3. Loops in Python
for i in range(5): print("Iteration:", i)
4. Functions in Python
def greet(name): return "Hello, " + name print(greet("Alice"))
Step 4: Install a Code Editor (Optional)
For better coding experience, use:
✅ VS Code – Download
✅ PyCharm – Download