Skip to content

Hello World in Python ๐Ÿš€

Mentor's Note: Every great developer started with this one line of code. Welcome to the world of programming! ๐Ÿ’ก


๐ŸŒŸ The Scenario: The First Meeting ๐Ÿค

Imagine you are meeting a new friend for the first time.

  • The Logic: You want to say "Hello" so they know you're there. ๐Ÿ“ฆ
  • The Result: A friendly greeting! In programming, we tell the computer to say "Hello" to us to prove everything is working. โœ…

๐Ÿ’ป Your First Script

Create a file named hello.py and write exactly this:

# ๐Ÿ›’ Scenario: Greeting the world
# ๐Ÿš€ Action: Using the built-in print function

print("Hello, World!")

# ๐Ÿ›๏ธ Outcome: The text appears on your screen

How to Run it?

  1. Open your terminal or command prompt.
  2. Navigate to the folder where you saved hello.py.
  3. Type: python hello.py

๐Ÿ“– Understanding the Code

  • print(): This is a built-in Function. Think of it as a worker whose only job is to put things on the screen.
  • "Hello, World!": This is a String (text). Strings MUST be inside quotes (" or ').
  • Parentheses (): These tell the function what data to work with.

๐Ÿง  Step-by-Step Logic

  1. Start ๐Ÿ
  2. Call the print worker.
  3. Hand the worker the message "Hello, World!".
  4. The worker displays the message.
  5. End ๐Ÿ

๐Ÿ“Š Sample Dry Run

Step Action Description
1 print() called Python finds the printing tool ๐Ÿ“ฅ
2 Argument received Message "Hello, World!" is loaded ๐Ÿ“ฆ
3 Execution Text is pushed to the terminal ๐Ÿ“ค

๐ŸŽฏ Practice Lab ๐Ÿงช

Task: Personalized Greet

Task: Modify your script to print your own name instead of "World". Bonus: Try printing two different messages on two different lines.


๐Ÿ“š Common Mistakes โš ๏ธ

  • Missing Quotes: print(Hello) will cause an error because Python thinks Hello is a variable.
  • Wrong Case: Print("Hi") will fail because print must be lowercase.

๐Ÿ’ก Pro Tip: "The best way to predict the future is to invent it." - Alan Kay


โ† Back: Installation | Next: Module 2 - Syntax & Comments โ†’