Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Writing a text-based program

      Lesson details

      Learning outcome

      I can create a text-based program from an algorithm that includes input and output.

      Key learning points

      1. An algorithm is a sequence of steps that can be followed to do a task.
      2. A program is a set of commands that can be run by a computer in order for it to do a task.
      3. All programming languages have rules for syntax that must be followed so that the program can run.
      4. The print() function is used to output information from a Python program.
      5. The input() function is used to input data from the user into a Python program.

      Keywords

      • Algorithm - a set of step-by-step instructions to solve a problem

      • Program - a set of commands that can be run by a computer in order for it to do a task

      • Syntax - the precise way that a program must be written to be understood by a computer

      Common misconception

      Pupils will modify their code to provide input directly in to the input() function, for example, user = input("Aisha"), rather than typing when asked as the program runs.

      The computer follows the instructions of a program. Input that a user has to type in should only be entered when the program runs. This allows different users to provide different inputs without changing the program in any way.

      Teacher tip

      Outputs can be produced from various combinations of strings and variables used in different orders. Encourage pupils to adjust the output of programs to make sense grammatically to the user by varying the placement of the variables used.

      Equipment

      Pupils will need access to a device that can edit and run Python programs. Examples in this lesson use the RPF Code Editor https://oak.link/python-editor

      Licence

      This content is © Oak National Academy Limited (2026), licensed on Open Government Licence version 3.0
      except where otherwise stated. See Oak's terms & conditions
      (Collection 2).

      Lesson video

      Loading...

      Prior knowledge starter quiz

      6 Questions

      Q1.
      A program is a set of __________ that can be run by a computer.

      Correct answer: commands
      directions
      points
      facts

      Q2.
      An is a sequence of steps that can be followed to do a task.

      Correct Answer: algorithm

      Q3.
      In this Scratch program, what is Hello World?

      An image in a quiz
      Correct answer: an output
      an input
      a variable

      Q4.
      In this Scratch program, what is the name of one of the variables?

      An image in a quiz
      Correct Answer: number, multiply-by

      Q5.
      A sequence is a precise set of instructions in a particular ...

      Correct Answer: order, format, style, step

      Q6.
      What would be the output for the following algorithm:
      123
      Repeat 3 times: Draw ✳✳✳♡ Draw ♡✳
      Code colour

      ✳✳✳♡✳✳✳♡✳✳✳♡♡✳
      Correct answer: ✳✳✳♡♡✳✳✳✳♡♡✳✳✳✳♡♡✳
      ✳✳✳♡♡✳♡✳♡✳
      ✳✳✳♡✳✳✳♡✳✳✳♡♡✳♡✳♡✳
      Q3 Scratch is a project of the Scratch Foundation. It is available for free at https://scratch.org. OR ScratchJr is a project of the Scratch Foundation. It is available for free at https://scratchjr.org. OR Scratch Foundation under CC BY-SA 2.0 Q4 Scratch is a project of the Scratch Foundation. It is available for free at https://scratch.org. OR ScratchJr is a project of the Scratch Foundation. It is available for free at https://scratchjr.org. OR Scratch Foundation under CC BY-SA 2.0

      5 Questions

      Q1.
      In programming, what is the term for the rules that specify the way that a program must be written?

      algorithm
      Correct answer: syntax
      flowchart
      command

      Q2.
      What type of error does the Python code pint("Success") have?

      runtime error
      Correct answer: syntax error
      logic error
      compilation error

      Q3.
      The Python code Print("Hello World!") has a syntax error. Rewrite the code correctly so that it doesn't have any syntax errors.

      Correct Answer: print("Hello World!"), print ("Hello World!")

      Q4.
      Which function is used to display text or other information on the screen in Python?

      input()
      output()
      Correct answer: `print()`
      show()

      Q5.
      What is the output of the following Python code?
      123
      print("What is your name?") name = input() print(f"Hello {name}")
      Code colour

      "What is your name? Hello"
      Correct answer: "What is your name?" followed by "Hello" and the users input
      "What is your name?" followed by "Hello name"
      "Hello" followed by the user's input

      To help you plan your 8 computing lesson on: Writing a text-based program, download all teaching resources for free and adapt to suit your pupils' needs...