Chapter 3 of 3

Free

1: The World of Programming Around Us

⏱️ 40-55 minutes
📊 beginner

Chapter 3: "Programs in Our Lives"

Alice, Professor Bit, and Byte were returning from the park when a light rain began to drizzle.

— Oh, it's starting to rain, — Alice noticed and automatically pulled a folding umbrella from her backpack.

— There! — the Professor exclaimed. — You just executed a program! "IF it's raining, THEN get the umbrella."

Alice blinked in surprise:

— Really? But I didn't even think about it, it was automatic.

— Many of our everyday actions are automatic programs we execute without thinking, — the Professor explained. — We call them habits or routines. Your morning routine, for example, is also a program.

[PLACE FOR POEM ABOUT DAILY PROGRAMS/HABITS]

— You know, — the Professor continued as they approached a crosswalk, — even traffic rules are a kind of program for organizing safe traffic.

The traffic light blinked and changed from red to green.

— Look, — said the Professor, — the traffic light works on a very simple algorithm:


REPEAT FOREVER:
TURN ON red light for 60 seconds
TURN ON green light for 40 seconds
TURN ON yellow light for 5 seconds

— And we, pedestrians, follow the program: "IF light is green, THEN walk, ELSE stop", — Alice added, crossing the street.

— Excellent! — praised the Professor. — You're starting to think like a programmer!

On the way, they stopped at a bakery. The aroma of fresh bread filled the room.

— Mmm, it smells so good, — said Alice. — I'd like a cinnamon roll.

— Do you know that the recipe for this roll is also a program? — asked the Professor as they stood in line. — The baker follows clear instructions: how much flour to add, what temperature to set, how long to bake.

Byte made a beep sound:

— A recipe is a perfect example of an algorithm! It has:

1. Input data — ingredients
2. Sequence of steps — instructions
3. Output data — finished dish

— Exactly, Byte, — the Professor nodded. — And what's interesting, recipes often contain all the basic elements of programming: sequence of actions, conditions, and loops.

— Conditions? — Alice asked again, receiving her roll.

— Of course! For example, "IF the dough is too dry, THEN add a bit more water." And loops — these are repeating actions, for example, "REPEAT whipping, WHILE fluffy foam doesn't form."

When they left the bakery, the rain had already stopped, and a rainbow appeared in the sky.

— Wow! — Alice admired. — How beautiful!

— And even the rainbow follows strict rules of physics, — Logic noted. — Water droplets refract sunlight always the same way, creating these seven colors in a strict sequence.

In the evening, they came to the Professor's house. Alice helped set the table, placing plates and cutlery.

— Professor, I just thought that setting the table is also a program, — the girl said. — First we put plates, then forks on the left, knives on the right...

— Right! — the Professor was pleased. — Many traditions and etiquette are social programs that help people interact with each other.

— What about games? — Byte asked, getting a chessboard. — Is chess also a program?

— Absolutely! — the Professor nodded. — Game rules are clearly defined algorithms. In chess, for example, each piece can only move according to certain rules.

[TASK:](Chapter 3 Programs in Our Lives/TASK.md)

Иллюстрация

Иллюстрация

Another task from the book

Do this without the code editor: use a notebook or the box below. Read the instructions carefully — each chapter’s task is different.

1. Pick a favorite game — board game, sport, playground game, or phone game (something you know the rules of well).

2. In a few sentences, write down how it is played: how many players, what happens at the start, how you decide the winner.

3. Rewrite the rules as an algorithm using ideas from the book: IF …, THEN …, REPEAT, WHILE (you do not need every construct — only what fits).

4. (Optional) Break down rock–paper–scissors: who goes first, what you compare, who wins each pairing — as steps and conditions.