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.

Кто запрограммировал меня
И придумал все мои влечения?
Просыпаться с первым светом дня,
Наслаждаться вкусностью печенья?

Кто заставил радугу сиять,
Загораясь в месте подходящем,
Чтобы эту радость передать
Всем друзьям и людям проходящим?

Кто расположил к полёту птиц,
Научил нырять в волну дельфинов?
Кто включает радость без границ,
В соки подливая эндорфинов?

Рано утром кто разбудит всех,
А под вечер дарит сон в постели?
Кто, воспламеняя детский смех,
Кружит нашу жизнь на карусели?

Каждого живого чистый лист
Наполняют коды мироздания.
Кто же этот тайный программист,
Что затронул струны созидания?

— 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.

Alice, the Professor and Byte at a crosswalk — the light turns 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.

In the bakery: the Professor with a recipe book, Alice with a bun, Byte explaining an algorithm

— 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?

Chess at the Professor's house: game rules as an algorithm

— 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)

Task

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.