My First Python Program: Hello World!
Want to learn coding? Start here! Write your first Python program and understand what code really does.
import CodePlayground from ’../../../components/CodePlayground.tsx’
What is Code?
Computers are really fast, but they’re not very smart. They can only do exactly what we tell them. Code is how we tell computers what to do — step by step.
Think of it like a recipe. If you tell someone to “make a sandwich,” they know what to do. But a computer needs every step:
- Get two slices of bread
- Put butter on one slice
- Put jam on top of the butter
- Put the other slice on top
- Cut in half
Code is the same idea — we write step-by-step instructions for the computer.
Why Python?
Python is one of the best languages to start with because:
- It reads almost like English
- No complicated symbols needed
- It’s used by scientists, engineers, and even NASA! 🚀
- The name comes from Monty Python (not the snake!) 🐍
Your First Program
Every programmer’s first program is “Hello World” — it just makes the computer say hello. Here it is:
print("Hello, I'm Nitvi!")
That’s it! print() tells the computer to show something on the screen. The text in quotes is called a string — it’s just text.
Try It in the Playground!
Use the code playground below to try different programs:
What’s Happening in the Code?
Let’s understand each sample:
Hello World
print("Hello, I'm Nitvi!")
print() shows text. Text in quotes is a string.
Counting Loop
for i in range(5):
print(f"Count: {i}")
for creates a loop that repeats. range(5) means “do it 5 times” (0, 1, 2, 3, 4).
The f"..." is called an f-string — it lets you put variables inside text using {}.
Simple Math
a = 10
b = 3
print(f"{a} + {b} = {a + b}")
Variables are like boxes that hold numbers. a = 10 puts 10 in a box called a.
Python can do math: +, -, * (multiply), / (divide).
Tips for Beginners! 💡
- Start small — one line at a time
- Make mistakes — that’s how you learn! Errors are your friends
- Read the code out loud — if it sounds like English, you understand it
- Change things — try modifying the code and see what happens
- Have fun! — coding is like solving puzzles
What’s Next?
Next time, we’ll learn about variables — the storage boxes of code. We’ll build a simple calculator together!
Until then, keep experimenting in the playground above! 💻✨