Author: Amanda McGarrigle

Computing—Term 1
We are adventure gamers—making a text-based adventure game

Background Information
In this unit, the pupils learn a few commands of a text-based programming language (Python), enabling progression from Scratch. They create a simple, text-based adventure game.
The pupils will be designing, writing and debugging a program with a specific goal in mind. They will be working in a text-based language, allowing them to compare and contrast this with Scratch, which they will have encountered previously. Encourage pupils to look for similarities and differences. It is important that pupils first plan their program before they start writing the code.
Python is used here in a form where commands are executed in sequence, just as blocks are used in Scratch. The pupils meet Python’s commands for repetition and selection, work with variables and a list, and use text-based input and output. They create their own functions to provide a clearer structure for their program. The pupils will encounter a new type of error (bug) in Python programming – the syntax error – where spelling or punctuation mistakes prevent Python from understanding the code they write. Fixing these mistakes is vital in text-based programming.

In this unit the children will…
learn some of the syntax of a text-based
programming language
use commands to display text on screen, accept
typed user input, store and retrieve data using
variables and select from a list
plan a text-based adventure with multiple ‘rooms’
and user interaction
thoroughly debug the program.
A template for a completed adventure, if you wish. See trinket.io/
python/7c35eac386

By the end of this unit….
All children will:
Type some commands at Python’s
interactive shell
Create a plan for a text-based adventure
Use the print command in Python
Use variables and selection in Python
Use procedures in Python
Create a list in Python
Most children will:
Correct mistakes in commands typed at Python’s interactive shell
Draw a graph to show the locations in a text-based adventure
Spot and correct syntax errors in Python print commands
Use variables and if / elif / else selection in Python
Define multiple procedures in Python, correctly observing the syntax rules
Choose randomly from a Python list
Some children will:
Experiment with commands using Python’s interactive shell, including the for and range commands
Describe tree-like graphs, such as one for a choose your own adventure game
Experiment with line-breaks and text blocks in Python print commands
Explain what a procedure is and explain what a library is in Python

The children will explore:
Get started with Python—explore Python - printing text on screen
Planning an adventure—plan using a tree-like graph
Printing descriptions—create a Python program
Using selection and variables—debugging syntax errors
Using procedures—change the graph of their game to create more complex structures,
Using lists—add further random elements to their game, perhaps combining two randomly chosen words in the same description. They could investigate how computers can make apparently random choices when they simply follow the instructions they are programmed to.

Key Vocabulary
Python: Text-based programming language, seen as suitable for beginners but used for real world programming, particularly in the academic community.
Debug: To fix the errors in a program.
Selection: A programming construct in which the instructions that are executed
are determined by whether a particular condition is met.
Sequence: To place programming instructions in order, with each executed one after the other.
Repetition: A programming construct in which one or more instructions are repeated, perhaps a certain number of times, until a condition is satisfied or until the program is stopped.
Variables: A way in which computer programs can store, retrieve or change simple data, such as a score, the time left, or the user’s name.
Input: Data supplied to a computer, typically via the keyboard or mouse.
Output: Information produced by computer processing systems, typically on the screen or through speakers.
Algorithm: An unambiguous set of rules or a precise step-by-step guide to solve a problem or achieve a particular objective.
Syntax: The correct spelling, punctuation and grammar for a text-based programming language.