Free lesson · Module 1, lesson 1 of 8

What a program is: a recipe for a computer

Explain what a program is with the chai recipe, say why order and exact wording matter to a computer, and spot the missing or out-of-order step in a set of instructions.

The video for this lesson is being prepared

About 9 minutes, narrated in English, Hindi and Odia. The notes and the quiz below are open now.

Lesson notes

What a program is

  • A program is a list of exact instructions, followed in order, by something that cannot guess
  • You already follow programs: making chai, directions to a friend's house, booking a bus ticket
  • Change the order or leave out a step, and the result goes wrong

A recipe and a program

  • Ingredients = data (values): what the steps work on
  • Steps = instructions: what to do, in order
  • The cook = the computer: carries out each step exactly
  • The cup of chai = the output: the result you see at the end

Finding a wrong order or a missing step

  • For each step, ask what it needs and which step makes that
  • A step goes after every step that makes what it needs (chai: 3, 2, 4, 1)
  • The missing step gives something a later step needs (the robot: put a tea bag in the cup)
  • A step that only sounds sensible, like switching off the kettle, is not the missing one

Read like a computer

  • One line at a time, top to bottom, exactly as written, nothing assumed

Try it

  • Lesson 3 shows how to open Python in Google Colab. Then type these three lines and run them: print("Wake up"), print("Brush teeth"), print("Drink chai")
  • The screen shows Wake up, Brush teeth and Drink chai, each on its own line
  • Swap the first and last lines and run again: the order on the screen follows the order of the code

Lesson quiz

Checked in your browser. Nothing is sent or saved.

5 questions

Question 1 · easy

Which sentence best describes a program?

Question 2 · easy

Priya checks her exam result on a website. She types her roll number and clicks Submit. The website looks up her marks in its records, and the page shows "Passed with 412 marks". Which part is processing?

Question 3 · medium

Arjun writes steps for a robot to plant a seed in a pot, but they got shuffled. Which order works?

Step 1: Water the soil on top of the seed
Step 2: Put a seed in the hole
Step 3: Dig a small hole in the pot
Step 4: Cover the seed with soil

Question 4 · medium

Sameer writes steps for a robot to charge his phone. One step is missing. Which one?

Step 1: Take the charger out of the drawer
Step 2: Plug the charger into the wall socket
Step 3: Switch on the socket
Step 4: Wait till the battery shows 100%
Step 5: Pull the cable out of the phone

Question 5 · hard

Nisha's auto-fare app follows these instructions. What does it show?

Put 30 in the box named fare
Put 20 in the box named tip
Add 10 to fare
Put 45 in fare
Show fare

Next: How a computer follows instructions