Chapter 1: Your First Program
Your First Program 🚀
Section titled “Your First Program 🚀”Every app, website, and game starts with code. In this chapter, you’ll learn what code really is — and write your very first program!
What is a Program?
Section titled “What is a Program?”A program program: A set of instructions written in a language that a computer can understand and follow. is a set of step-by-step instructions for a computer. Just like a recipe tells you how to bake a cake, a program tells a computer how to do something.
Here’s your very first Python program:
print("Hello, world!")When a computer runs this code, it prints the words Hello, world! on the screen. That’s it — you just read your first program!
Breaking It Down
Section titled “Breaking It Down”Let’s look at each part:
| Part | What It Does |
|---|---|
print() | Tells the computer to display something on the screen |
"Hello, world!" | The string string: A piece of text in a program, always surrounded by quotation marks. (text) you want to display |
Try It Yourself
Section titled “Try It Yourself”Here are some things to try. Change the text inside the quotes and see what happens!
print("My name is ___!")print("I am ___ years old.")print("My favorite subject is ___.")What is a Variable?
Section titled “What is a Variable?”A variable variable: A named container that stores a value, like a labeled box that holds something inside. is like a labeled box where you can store information:
name = "Alex"age = 10print("Hi, my name is " + name)print("I am " + str(age) + " years old")You can change what’s inside a variable at any time — that’s why it’s called a variable!
Quick Check 🤔
Section titled “Quick Check 🤔”- What does the
print()function do? - Why do we put quotes around text in Python?
- If you wrote
greeting = "Hey there!", what wouldprint(greeting)show on the screen?