Skip to the page
Year 8 · Spring 2 · Python I

print, input and sequence

PracticalPresent ▶

What this lesson covers

Topic 11 Algorithms

KS3 Computing · An algorithm is a precise, step-by-step plan to solve a problem. Computational thinking turns a messy problem into one. Every algorithm is built from just three things: sequence, selection and iteration.

Topic 13 Programming basics

KS3 Computing · A program stores information in variables, works on it with operators, and controls the order with sequence, selection and iteration. Examples are in Python, with Scratch alongside for Year 7.

ProgrammingCambridge Lower Secondary Computing 0860

You will learn to

  • Use print() to show text on the screen.
  • Use input() to ask a question and store the answer in a variable.
  • Explain that Python runs one line at a time, from top to bottom.
  • Predict what a short program will show before you run it.

Success criteria

  • I can write a program that asks for my name and says hello to me by name.
  • I can predict the output of a program, then run it to check.
  • I can save my programs with the agreed names.

Key words

Say each word, then read what it means. Every one is in the glossary too.

casting
Changing a value from one data type to another, like int("13").
Algorithm
Precise, ordered, finite steps to solve a problem.
Decomposition
Breaking a problem into smaller ones.
Abstraction
Ignoring detail that doesn't matter for the problem.
Sequence · selection · iteration
Steps one after another. First this, then this.
Pseudocode
Code-like writing for algorithms, without strict rules.
Trace table
Records variable values step by step to check logic.
Variable
A named place in memory that holds a value.
Assignment
Storing a value in a variable. = in Python, ← in pseudocode.
Concatenation
Joining strings together: "7" + "7" = "77".
Selection
Choosing a path with if / else.
Iteration
Repeating steps: a loop.
Boolean
A value that is only True or False.
Infinite loop
A loop whose condition never becomes false.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

Inputs, process, outputs

★Remember

Before writing an algorithm ask: what goes in? What must happen? What comes out?

Input and casting

name = input("What is your name? ")
age = int(input("How old are you? "))
print("Hi " + name + ", next year you'll be " + str(age + 1))
  1. input() always gives back a string, even if you type digits.
  2. int() turns "13" into 13 so you can do maths. This is casting.
  3. str() turns 14 back into text so it can join other text.

Study it

Open the study page and go one step at a time.

Pages to explore

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.