AiTechWorlds
AiTechWorlds
Remember your first day at a new job? You walked in, maybe a little nervous, and at some point someone asked you to introduce yourself to the team. "Hi, I'm Alex. I'm the new junior developer." Simple sentence. Huge moment. You existed in that room before, but now the room knew you existed.
Your first program does the same thing. It's your code introducing itself to the world — saying "I'm here, I'm running, and I work." It's a tradition as old as programming itself, and today you're joining it.
In 1972, Brian Kernighan wrote a small example program in a tutorial for the B programming language. It printed the words "hello, world" to the screen. It wasn't the first such program, but it stuck. The phrase became a cultural touchstone — the universal first step every programmer takes when learning a new language.
Today, writing "Hello, World!" is essentially a rite of passage. It means:
It sounds small. It isn't.
Open VS Code (or IDLE), create a new file called hello.py, and type this:
print("Hello, World!")
That's it. That's the whole program.
Now let's break down every single piece of that one line, because each part matters.
| Part | Name | What It Does |
|---|---|---|
print | Function name | A built-in Python command that displays text on the screen |
( ) | Parentheses | Tell Python "here come the inputs to this function" |
"Hello, World!" | String (text) | The actual text you want to display, wrapped in quotes |
print is a function — a named action that Python knows how to perform. Think of it like pressing a button labeled "display this on screen."print will work with.Hello is a variable name and get confused.Running the program in VS Code:
View → Terminal (or press Ctrl+`)python hello.py and press EnterHello, World!
One line in, one line out. Clean, simple, perfect.
Now that it works, let's make it yours. Change the file to:
print("Hello, World!")
print("My name is Alex.")
print("I am learning Python.")
Output:
Hello, World!
My name is Alex.
I am learning Python.
Each print() call creates a new line of output. You can have as many as you want. Notice Python runs them top to bottom, in order — just like our chef following a recipe.
Here's something important: you can leave notes inside your code that Python completely ignores. These are called comments, and they start with a # symbol.
# This is my first Python program
# Written on my first day of learning
print("Hello, World!") # This line prints the greeting
print("My name is Alex.")
Comments are for people, not the computer. Python skips over anything after a # on a line. Use them to:
Good habit: Write comments like you're leaving notes for someone who has no idea what your code is supposed to do. Because six months from now, that someone might be you.
Let's level up. Here's a program that does some real work:
# Simple calculator
num1 = 10
num2 = 5
result = num1 + num2
print("The answer is:", result)
Line by line:
| Line | What It Does |
|---|---|
# Simple calculator | Comment — Python ignores this, it's just a label |
num1 = 10 | Creates a variable called num1 and stores the number 10 in it |
num2 = 5 | Creates a variable called num2 and stores the number 5 |
result = num1 + num2 | Adds num1 and num2 together, stores the result (15) in result |
print("The answer is:", result) | Prints the text "The answer is:" followed by the value of result |
Output:
The answer is: 15
Notice that print() here takes two things separated by a comma: a piece of text and a variable. Python prints both, with a space between them. This is how you mix fixed text with variable data.
Everyone makes these mistakes. Everyone. Here's what they look like and what to do:
Error 1: Missing quotes
print(Hello, World!)
Error message:
File "hello.py", line 1
print(Hello, World!)
^
SyntaxError: invalid syntax
Fix: Add quotes around the text — print("Hello, World!")
Error 2: Misspelling print
Print("Hello, World!")
Error message:
NameError: name 'Print' is not defined
Fix: Python is case-sensitive. print must be all lowercase — print("Hello, World!")
Error 3: Missing closing parenthesis
print("Hello, World!"
Error message:
File "hello.py", line 1
print("Hello, World!"
^
SyntaxError: '(' was never closed
Fix: Every opening ( needs a closing ) — print("Hello, World!")
Reading error messages is a skill. Don't panic when you see red text. Look for the line number (it tells you where the problem is) and the error type (it tells you what the problem is). With practice, you'll read error messages as naturally as reading a sentence.
# My personal introduction
# This program introduces me to the world
print("=" * 30) # Print a decorative line
print("Hello, World!")
print("My name is Alex Johnson.")
print("I live in New York City.")
print("I am learning Python programming.")
print("=" * 30)
Output:
==============================
Hello, World!
My name is Alex Johnson.
I live in New York City.
I am learning Python programming.
==============================
The "=" * 30 is a fun trick — Python repeats the = character 30 times. More on this in a later lesson, but it shows you that even small programs can have style.
Write a program that prints:
Save it as introduction.py and run it. If it displays your information without any errors — congratulations. You're a Python programmer.
Seriously, do the challenge. Reading about programming and writing code are completely different experiences. Your fingers need to type the code. Your eyes need to see it run. That's how the knowledge sticks.
print() displays text and values to the screen' or double " both work# and are ignored by Python — they're notes for humansprint works, Print does notprint() call outputs on its own lineGet this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises