What is Python?
Python is a high-level, interpreted programming language created by Guido van Rossum in 1991. It's designed to be easy to read and write, making it perfect for beginners while being powerful enough for professionals.
Key Characteristics
- Easy to Read: Python code looks almost like English
- Interpreted: No compilation needed; run code immediately
- Versatile: Used for web, data science, AI, automation, and more
- Large Community: Millions of developers worldwide
- Extensive Libraries: Pre-built tools for almost anything
Why Learn Python?
1. Beginner-Friendly
Python has simple, clean syntax that's easy to understand:
# Python print("Hello, World!")
Compare to Java:
// Java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
2. High Demand in Job Market
- Data Science: #1 language for data analysis
- Web Development: Powers Instagram, YouTube, Spotify
- Automation: Save hours with scripts
- AI/Machine Learning: TensorFlow, PyTorch
- Average Salary: $95,000+ for Python developers
3. Versatile Applications
- Web apps (Django, Flask)
- Data analysis (Pandas, NumPy)
- Machine learning (scikit-learn)
- Game development (Pygame)
- Desktop apps (Tkinter, PyQt)
- Scripting and automation
Your First Program: Hello, World!
Every programmer's journey starts here. Let's write your first Python program!
Step 1: Create a File
- Open your code editor
- Create a new file called
hello.py - Save it in your workspace folder
Step 2: Write the Code
Type this exactly:
print("Hello, World!")
Step 3: Run the Program
In VS Code:
- Click the "Run" button (▶️ top right), or
- Press F5, or
- Right-click → "Run Python File in Terminal"
In Terminal/Command Prompt:
python hello.py # Windows python3 hello.py # macOS/Linux
Expected Output
Hello, World!
🎉 Congratulations! You're officially a Python programmer!
Understanding the Code
print("Hello, World!")
Let's break it down:
print: A built-in function that displays output(): Parentheses contain what to print"Hello, World!": A string (text) in quotes- No semicolon: Unlike many languages, Python doesn't require
;at line ends
Try These Variations
Multiple Messages
print("Hello, World!") print("I am learning Python!") print("This is exciting!")
Output:
Hello, World!
I am learning Python!
This is exciting!
Print Numbers
print(42) print(3.14159) print(100 + 50)
Output:
42
3.14159
150
Print Multiple Items
print("The answer is", 42) print("Pi is approximately", 3.14159) print("I am", 25, "years old")
Output:
The answer is 42
Pi is approximately 3.14159
I am 25 years old
Common Mistakes
1. Forgetting Quotes
# ❌ Wrong print(Hello, World!) # ✅ Correct print("Hello, World!")
2. Mixing Quote Types
# ❌ Wrong print("Hello, World!') # ✅ Correct print("Hello, World!") # or print('Hello, World!')
3. Typos in Function Name
# ❌ Wrong Print("Hello") # Capital P # ✅ Correct print("Hello") # lowercase p
Practice Exercises
- Print your name
- Print your age
- Print your favorite hobby
- Print a message with both text and numbers
- Print multiple lines to create a simple pattern
Example Solution:
print("My name is Alice") print("I am 25 years old") print("I love programming") print("I have", 3, "pets") print("*****") print("*****") print("*****")
Key Takeaways
✅ Python is easy to learn and powerful
✅ print() displays output to the screen
✅ Strings go in quotes (" or ')
✅ Python is case-sensitive
✅ No semicolons needed at line ends
Next Lesson: Variables and Data Types