What is Python?
Python is a high-level, interpreted programming language known for its simplicity and readability. Created by Guido van Rossum in 1991, it's now one of the most popular programming languages worldwide.
🎯 Why Learn Python?
- Easy to Learn: Simple, English-like syntax perfect for beginners
- Versatile: Web development, data science, AI/ML, automation, scripting
- Huge Community: Extensive libraries, frameworks, and support
- Cross-Platform: Runs on Windows, macOS, and Linux
- High Demand: Top skill in job market across industries
- Rapid Development: Write less code, achieve more
💻 Your First Python Program
# Hello World in Python
print("Hello, World!")
# Output: Hello, World!
📦 Installation
# Download from python.org
# Or use package managers:
# macOS (Homebrew)
brew install python3
# Linux (Ubuntu/Debian)
sudo apt update
sudo apt install python3 python3-pip
# Windows (Chocolatey)
choco install python
# Verify installation
python3 --version
# Output: Python 3.11.x
# Check pip (package manager)
pip3 --version
🚀 Running Python
# Interactive Mode (REPL)
python3
>>> print("Hello")
Hello
>>> 2 + 2
4
>>> exit()
# Run Python File
python3 script.py
# Python in VS Code
# 1. Install Python extension
# 2. Select interpreter (Cmd+Shift+P → Python: Select Interpreter)
# 3. Run with F5 or Run button
📝 Python Syntax Basics
# Comments start with #
# This is a comment
# Variables (no declaration needed)
name = "Alice"
age = 30
height = 5.6
is_student = True
# Print output
print(name) # Alice
print(f"{name} is {age} years old") # Alice is 30 years old
# Indentation matters (no braces)
if age >= 18:
print("Adult") # 4 spaces or 1 tab
print("Can vote")
# Case sensitive
Name = "Bob" # Different from 'name'
🎯 Key Takeaways
- Interpreted Language: No compilation step required
- Dynamic Typing: Variables don't need type declarations
- Indentation: Uses whitespace (4 spaces) for code blocks
- print(): Display output to console
- Comments: Use # for single-line comments
- REPL: Interactive Python shell for testing
- Case Sensitive: name and Name are different variables