🐍 Python Course in 4 to 6 Weeks – Lesson 3: Writing Your First Python Program – Hello, World!
Welcome back to our Python Course in 4 to 6 Weeks! 🎉 In this lesson, you'll finally write your first line of code using Python. We'll explain how Python interprets your instructions and how to print messages to the screen using the famous Hello, World!
example.
✅ What You’ll Learn
- How to open your Python environment (VS Code, Replit, or terminal)
- How to write your first Python script
- What
print()
does and why it’s important - Basic debugging tips if things don’t work
🖥️ Step 1: Open Your Python Environment
You can write Python code using any of these methods:
- 📝 VS Code: Open a new file, save it with
.py
extension - 🌐 Replit: Go to https://replit.com/languages/python3 and start typing
- 📟 Command Line: Type
python
and hit Enter
📄 Step 2: Your First Python Code
Create a new file called hello.py
and type the following line:
print("Hello, World!")
Then run it:
- ⚙️ In VS Code: Right-click the file and choose "Run Python File in Terminal"
- 📟 In terminal: Navigate to the file’s directory and type
python hello.py
🔍 How It Works
The print()
function is used to display text on the screen. In this case, it prints Hello, World!
. This is the traditional first step in learning any new language – it confirms that your environment is working correctly.
⚠️ Common Errors
- ❌ Missing quotation marks:
print(Hello, World!)
→ ❌ Error - ❌ Wrong file extension: Make sure your file ends with
.py
- ❌ Wrong command: Use
python
notpythn
🧠 Mini Challenge
Try printing your name instead! Change the code to:
print("Hello, my name is Amr!")
🎯 Bonus: Try printing multiple lines using multiple print()
statements.
📥 Tools You'll Need
- 🐍 Python: https://www.python.org/downloads/
- 📝 VS Code: https://code.visualstudio.com/
- 🌐 Replit: https://replit.com/languages/python3
📌 Final Words
👏 Great job! You've just written and run your first Python program. Keep practicing, and don’t worry if you make mistakes — that’s how you learn.
🔗 Coming Next:
Lesson 4: Variables & Data Types in Python – Storing Information the Smart Way 🧠💾