Python Course in 4 to 6 Weeks – Lesson 3: Writing Your First Python Program – Hello, World!

🐍 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:

📄 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 not pythn

🧠 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

📌 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 🧠💾

Post a Comment