Cambridge Lower Secondary Computing 9 Teacher's Guide with Boost Subscription - sample pages

Page 6

©Hodder Education

Barnes Margaret Debbadi Pam Jones Tristan Kirkpatrick Series editor: Lorne Pearcey

TEACHER’S
Computing
GUIDE 9
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 1 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd Sample
Ben

Endorsement indicates that a resource has passed Cambridge International’s rigorous quality-assurance process and is suitable to support the delivery of a Cambridge International curriculum framework. However, endorsed resources are not the only suitable materials available to support teaching and learning, and are not essential to be used to achieve the qualification. Resource lists found on the Cambridge International website will include this resource and other endorsed resources.

Any example answers to questions taken from past question papers, practice questions, accompanying marks and mark schemes included in this resource have been written by the authors and are for guidance only. They do not replicate examination papers. In examinations the way marks are awarded may be different. Any references to assessment and/or assessment preparation are the publisher’s interpretation of the curriculum framework requirements. Examiners will not use endorsed resources as a source of material for any assessment set by Cambridge International.

While the publishers have made every attempt to ensure that advice on the qualification and its assessment is accurate, the official curriculum framework, specimen assessment materials and any associated assessment guidance materials produced by the awarding body are the only authoritative source of information and should always be referred to for definitive guidance. Cambridge International recommends that teachers consider using a range of teaching and learning resources based on their own professional judgement of their students’ needs.

Cambridge International has not paid for the production of this resource, nor does Cambridge International receive any royalties from its sale. For more information about the endorsement process, please visit www.cambridgeinternational.org/endorsedresources

Cambridge International copyright material in this publication is reproduced under licence and remains the intellectual property of Cambridge Assessment International Education.

Third-party websites and resources referred to in this publication have not been endorsed by Cambridge Assessment International Education.

Hachette UK’s policy is to use papers that are natural, renewable and recyclable products and made from wood grown in well-managed forests and other controlled sources. The logging and manufacturing processes are expected to conform to the environmental regulations of the country of origin.

Orders: please contact Hachette UK Distribution, Hely Hutchinson Centre, Milton Road, Didcot, Oxfordshire, OX11 7HH. Telephone: +44 (0)1235 827827. Email: education@hachette.co.uk. Lines are open from 9 a.m. to 5 p.m., Monday to Friday. You can also order through our website: www.hoddereducation.com.

ISBN: 978 1 3983 6981 8

© Margaret Debbadi and Pam Jones 2023

First published in 2023 by Hodder Education, An Hachette UK Company Carmelite House 50 Victoria Embankment London EC4Y 0DZ

www.hoddereducation.com

Impression number 10 9 8 7 6 5 4 3 2 1 Year 2027 2026 2025 2024 2023

All rights reserved. Apart from any use permitted under UK copyright law, no part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording, or held within any information storage and retrieval system, without permission in writing from the publisher or under licence from the Copyright Licensing Agency Limited. Further details of such licences (for reprographic reproduction) may be obtained from the Copyright Licensing Agency Limited, www.cla.co.uk

Cover photo [to follow]

Illustrations by [typesetter: please complete]

Typeset in [typesetter: please complete]

Printed in [to follow]

A catalogue record for this title is available from the British Library.

Sample ©Hodder Education

369818_FM_Camb_LS_CS9_TG_001-009.indd Page 2 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd
3 Introduction 4 About the series 4 How to use this series 6 A ssessment 7 Software and hardware 8 9.1 Presenting choices: Combining constructs 10 9. 2 Design your own network: Shape and size 65 9. 3 Coding and testing: Game development for the micro:bit 97 9.4 Drilling down: How the processor processes 143 9.5 Big Data modelling and analysis: Databases and spreadsheets 182 9.6 An array of skills 214 Acknowledgements 248 Contents 369818_FM_Camb_LS_CS9_TG_001-009.indd Page 3 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder Education

Introduction

About the series

Cambridge Lower Secondary Computing is a series consisting of a Student’s Book, a Boost eBook of the Student’s Book, and a Teacher’s Guide with Boost online resources for each stage of the Cambridge Lower Secondary Computing curriculum framework (0860) from 2021.

The series aims not only to encompass the Cambridge Lower Secondary Computing curriculum framework, but also to embody the Cambridge Learner and Teacher Attributes. The wide range of materials stimulates appeal and sparks curiosity, enabling students to become motivated and engaged. Collaboration is encouraged through pair work and group tasks, allowing students to be supportive of each other’s progress. Engaging units and themes are used to present real-world, contextualised scenarios to allow learners to explore and develop new concepts and provide plugged and unplugged activities that will allow students to develop, reinforce and contextualise their understanding and computing skills.

The books are written by experienced authors and secondary practitioners to reflect a spiral curriculum model and support the Use–Modify–Create approach to teaching Computer Science covering the outcomes of the Cambridge Lower Secondary Computing curriculum framework. The content of each of the components of the series is outlined below.

Student’s Book

The Student’s Book develops students’ computing competency across the five strands of the curriculum framework: computational thinking; programming; managing data; networks and digital communication; and computer systems.

There are six units in each Student’s Book, which enable students to explore the learning objectives through engaging themes and scenarios. The units in this Teacher’s Guide for Stage 9 are:

l 9.1 Presenting choices: Combining constructs

l 9.2 Design your own network: Shape and size

l 9.3 Coding and testing: Game development for the micro:bit

l 9.4 Drilling down: How the processor processes

l 9.5 Big Data modelling and analysis: Databases and spreadsheets

l 9.6 An array of skills

Units are divided into themes that practise the skills and constructs of the learning objectives. Each unit contains the following features:

l Get started! Activities that introduce the unit and provide some initial unplugged tasks.

l Learning outcomes A list outlining the key learning objectives of the unit.

l Warm up Unplugged tasks, usually linked to a computational thinking strand.

l Scenario Setting the activities in the unit in context; the main constructs covered in the unit are also outlined within the ‘Scenario’.

l Do you remember? A summary of the skills, knowledge and understanding that students will need (from previous stages) to attempt the unit.

l Learn Introduces new concepts, principles, operations and key knowledge.

4
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 4 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

l Practise Activities that consolidate, reflect on and further develop understanding of the concepts in the ‘Learn’ box; practice of different aspects of computational thinking are frequently built into these activities.

l Go further A set of more detailed activities that focus on one or more of the constructs covered.

l Keywords Definitions of important vocabulary, including technical terms that are crucial for the constructs in question; written with ESL students in mind.

l Did you know? Occasional interesting facts that are related to the theme or unit.

l Challenge yourself Activities that challenge students to take concepts further.

l Final project A series of activities that pulls together the skills and constructs from the unit; the ‘Final project’ provides teachers with a more formal assessment opportunity.

l Evaluation A structure to evaluate the ‘Final project’; this can be used for self-assessment or peer-assessment.

l What can you do? A summary of the constructs that a student should have a deep understanding of after fully completing the unit; these statements match the success criteria used in the Teacher’s Guide and are linked directly to the learning outcomes listed at the start of the unit.

l Speech bubbles Hints and tips to help clarify important information in the activities.

l Computational thinking An occasional box that highlights aspects of computational thinking related to the theme through a discrete activity.

There is also a Glossary and Index at the back of the Student’s Book.

Program files used in the Student’s Book activities can be downloaded for free from: www. hoddereducation.com/cambridgeextras (The resources are also available in the Boost course for convenience.)

These files appear in red bold font in the Student’s Book (e.g. QuizGameV1.py).

Teacher’s Guide

Each unit in the Teacher’s Guide is divided into ten lessons, each lesson covering a theme (or several themes) from the Student’s Book.

The Student’s Book and Teacher’s Guide together provide material for approximately two hours of computing lessons per week, over a ten-week term. However, the content of the Teacher’s Guide can be used flexibly, as per your school’s timetable.

The Teacher’s Guide supports the activities in the Student’s Book through:

l a learning objectives overview table at the start of each unit

l background information

©Hodder Education

l prior knowledge summary

l a table of learning objectives and related success criteria for each lesson, to share with students

l starter activity suggestions

l Student’s Book activity notes and answers

l links to the accompanying Boost online resources and answers

l review ideas and answers

l homework suggestions and answers

l differentiation ideas for stretch/support of the ‘Practise’ activities

l these icons highlight where teachers could assess students’ understanding of the constructs, either during or after the activity.

5
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 5 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd
Sample

Boost online resources

The Boost online resources support the activities in the Student’s Book and Teacher’s Guide. These resources are referenced at the start of (and within) each lesson in the Teacher’s Guide.

The resources reinforce learning through: l slideshows l visuals (artworks, photos, diagrams and tables) l worksheets (answers to worksheets are shown with an * in the Teacher’s Guide lesson notes) l flashcards with definitions of the keywords from the Student’s Book l additional program files to support some of the ‘Learn’/’Practise’ tasks l solutions to the program files in the Student’s Book; these are shown through the addition of (Teacher) in the program filename l knowledge tests l an eBook of the Student’s Book.

How to use this series

Students should complete the units (and themes) in order in the Student’s Book. Students must complete the ‘Get started!’, ‘Warm up’, ‘Learn’, ‘Practise’, ‘Go further’ and ‘Final project’ tasks as a minimum requirement. This will ensure complete coverage of the learning objectives of the Cambridge Lower Secondary Computing curriculum framework for the stage.

The activities are designed to build on previous knowledge as your class progresses through the Student’s Book and Teacher’s Guide lessons. The ‘Challenge yourself’ tasks might not be completed by all students and, therefore, do not count towards full coverage of the learning objectives.

Differentiation

Differentiation is the adjustment of the teaching and learning process so that different needs of students can be accommodated, and individual learning maximised. The Student’s Book assumes the spiral curriculum model and supports the Use–Modify–Create approach that all students will be able to learn the material, given sufficient time and direction. Differentiation is built into the material, with tasks in each ‘Practise’ box slowly increasing in difficulty throughout the unit. The ‘Go further’ tasks offer students further stretch. The ‘Challenge yourself’ tasks offer students who are able to grasp the constructs quickly additional challenges to work on independently.

Differentiation suggestions for stretch and support are also provided in each Teacher’s Guide lesson, linked to the ‘Practise’ tasks.

Key strategies for differentiation are built into the teaching notes and include:

l skilful questioning within lessons to develop conceptual understanding – questions are frequently provided to check students’ understanding in the starter suggestions and lesson notes

l identifying misconceptions or common mistakes that arise and eliminating them quickly – these are highlighted in the lesson notes

l challenging students who grasp the concepts rapidly to explore the constructs further, rather than immediate acceleration to new material – suggestions are provided in the ‘Differentiation’ section of the lesson

6
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 6 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

l supporting students who take longer to understand ideas by providing further examples and demonstrations on the teacher computer or breaking down the constructs into smaller stages and moving on only when students are confident – suggestions are provided in the ‘Differentiation’ section of the lesson

l peer-to-peer support through pair and group activities – the Student’s Book contains frequent paired (and some group) activities in the ‘Practise’ tasks.

Assessment Learning objectives

In the Teacher’s Guide, an overview of all the learning objectives is given at the start of each unit. The learning objectives (and codes) relevant to the Student’s Book themes are also given at the start of each lesson. These are paired with specific success criteria.

It is good practice to share success criteria with students at the beginning of each lesson. This will ensure that they are clear on the focus of each lesson and what they are expected to learn. At the end of each lesson, and as part of the review, ask students to reflect on what they have learned and check their understanding against the success criteria.

Formative assessment

Formative assessment is a form of ongoing assessment that occurs in every lesson. It informs the teacher and the students of the progress that they are making, linked to the success criteria.

Formative assessment is important because it means that teachers and students are continually reflecting on how the learning is moving forward. Where necessary, teachers can work with students during the lesson to support issues as they emerge.

Formative assessment should be used to inform the next steps of learning, and may influence changes in planning and therefore the next lessons. Formative assessment is a cycle: finding out what students know, moving learning forward, finding out how that learning has changed (what they know now) and planning the next steps.

Opportunities for formative assessment are flagged in the Teacher’s Guide lesson notes using the icon . As you review students’ responses to tasks in the Student’s Book, where you find students are still unsure, stop and take time to revisit a concept or skill, and change the activity or context. Move on to new learning once learning is secure.

At the start of each lesson, suggestions for success criteria are given. The success criteria are used to assess the outcome of the learning that has taken place. The success criteria are, in effect, what the successful learning will look like once the learning objectives have been met.

At the end of each unit in the Student’s Book, the ‘Evaluation’ and ‘What can you do?’ boxes also form part of the formative assessment process. The statements in the ‘What can you do?’ box match those in the success criteria used throughout the unit.

7
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 7 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

Peer feedback

Giving and receiving peer feedback ensures that students gain confidence and develop their own learning techniques. It also provides teachers with more time to facilitate formative feedback with individual students. The first time you ask students to give peer feedback, go through some examples of what good peer feedback looks like and ensure that students understand that they are giving supportive suggestions to each other.

Students can give peer feedback by: l giving comments about a specific design, solution or idea l offering a solution or strategy to improve work, including possible revisions or suggested examples l leaving their peers with something to think about or take action on l ensuring that their feedback directly references the task, requirements or skill l being kind and supportive in the way they word their comments and suggestions.

Final projects and knowledge tests

While the course is not formally assessed, the ‘Final project’ at the end of each unit provides an opportunity to assess the skills that students have gained through the unit. Here, students work independently on a series of tasks to demonstrate their knowledge, skills and understanding of some of the learning outcomes linked to the ‘Scenario’ at the start of the unit. Note that not all the learning objectives are covered in the final project. Do check carefully through the list of learning objectives.

The Boost online resources also provide a quiz for every unit of the Student’s Book. Recording the results from these quizzes will enable teachers to see where a student’s strengths and weaknesses lie. Teachers can then use this information to provide extra support and practice for students where needed.

For a visual representation, teachers could use the results to perform a RAG (red–amber–green) analysis. Highlight scores from 1 to 19 as red, meaning further support is needed; scores from 20 to 31 as amber, meaning that learners have mostly understood but need support in some areas; and scores from 32 to 40 as green, meaning that learners have a good understanding and few weaknesses.

The quiz questions each have a clear focus, such as understanding keywords, understanding program code, and key concepts from the module. Recording the results of each individual question would enable teachers to see which specific aspects students as a class are stronger in and in which they are less confident. Analysis of this nature can help teachers to reflect on their own practice and consider whether classroom techniques could be changed or adapted in the future.

The ‘Review’ sections of the Teacher’s Guide give an opportunity to revisit learning from the lesson and can be used to assess whether students have understood concepts and how well they are able to apply them to a scenario.

Software and hardware

A summary of the software and hardware needed is given at the start of each unit in the Student’s Book and each Teacher’s Guide lesson.

Students will need access to the following on their personal devices to complete the activities in the Student’s Book: l a web browser and an active internet connection l word-processing software, e.g. Microsoft Word

Sample ©Hodder Education

8
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 8 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd

l presentation software, e.g. Microsoft PowerPoint l spreadsheet software, e.g. Microsoft Excel l database software, e.g. Microsoft Access l Python

l MicroPython – https://python.microbit.org/ l a micro:bit and USB connection cable l a flowchart-drawing application, e.g. https://app.diagrams.net (optional).

Note: Students are not being assessed on their skills in the use of word-processing or presentation applications, as these do not form part of the curriculum framework. However, these applications are sometimes suggested as a tool for students to use when completing the activities. It is presumed that students have a basic understanding of such applications before starting the course. Worksheets, for example, could be completed digitally or by hand on a printed copy.

©Hodder Education

9
369818_FM_Camb_LS_CS9_TG_001-009.indd Page 9 28/12/22 1:48 PM f-0229-MAC /103/HO02751/work/indd
Sample

Presenting choices: Combining constructs 9.1

Learning objectives overview

These learning objectives and associated codes are reproduced from the Cambridge Lower Secondary Computing curriculum framework (0860) from 2021. This Cambridge International copyright material is reproduced under licence and remains the intellectual property of Cambridge Assessment International Education.

Learning objective

Follow, understand, edit and correct algorithms that are presented as pseudocode.

Follow flowchart or pseudocode algorithms that use loops.

Know how to create algorithms using flowcharts and pseudocode.

Understand and use iteration statements, limited to count-controlled loops, presented as either flowcharts or pseudocode.

Predict the outcome of algorithms that use iteration.

Compare and contrast algorithms designed for the same tasks to determine which is best suited to the purpose.

Combine multiple constructs (sequence, selection, count-controlled iteration) to write algorithms as flowcharts or pseudocode.

Curriculum framework code Student’s Book pages Teacher’s Guide pages Online resources Computational thinking

9CT.01 49–50 53–54

9CT.02 34–35, 37–38 36–37, 40–41

9CT.03 9, 44–45, 52 15, 43–46, 58–59

9CT.06 34–35, 52 36–37, 60

9.1 Knowledge Test

9.1.5 Worksheet 8

9.1.6 Worksheet 10

9CT.07 37–38 40–41 9.1.5 Worksheet 9

9CT.08 34–35 36–37

©Hodder Education

9CT.09 44–45, 52 43–46, 58–59

10
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 10 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

9.1 Presenting choices: Combining constructs

Learning objective

Explain the purpose of a one-dimensional array.

Identify and describe data types in text-based programs, including integer, real, character, string and Boolean.

Know how to develop text-based programs with count-controlled loops.

Know how to access data from an array using a textbased language.

Know how to develop text-based programs using string manipulation, including length, uppercase and lowercase.

Use iterative development on software prototypes to produce solutions to problems.

Evaluate the processes that are followed to develop programs.

Know how to develop and apply test plans that include normal, extreme and invalid data.

Identify test data that covers normal, extreme and invalid data.

Curriculum framework code Student’s Book pages Teacher’s Guide pages Online resources Programming

9P.01 37–38, 44–45, 52 40–41, 43–46, 60

9.1.6 Worksheet 11 9.1 Knowledge Test

9P.02 15, 52 17–18, 58 9.1.1 Worksheet 1 9.1.1 Worksheet 2 9.1.5 Worksheet 9

9.1 Knowledge Test

9P.03 30, 34–35, 37–38 35, 36–37, 40–41 FoodSelection ChatbotV3.py

9.1.6 Worksheet 10 9.1.5 Worksheet 8

9P.04 30, 34–35, 37–38 40–41, 63 9.1.6 Worksheet 10 9.1.7 Worksheet 12

9P.05 49–50, 53 53–54, 63 stringManipulation.py

9.1 Knowledge Test

9P.06 18, 28, 44–45, 53 21–22, 30–33, 43–46, 63

9P.07 53 63

pizzaChatbotV3.py ActivitiesChatbotV3.py

Identify a range of errors, including syntax, logic and runtime errors.

9P.08 48, 53 49–50, 63 TestProgram.py 9.1.8 Worksheet 13

9P.09 48, 53 49–50, 63 TestProgram.py 9.1.8 Worksheet 13 9.1.8 Worksheet 14

9.1 Knowledge Test

9P.10 28, 48, 53 30–33, 49–50, 63

9.1.4 Worksheet 7 TestProgram.py 9.1.8 Worksheet 13

9.1.8 Worksheet 14 travelChatbotV1.py

9.1 Presentation 9.1.4 Visual 2

Sample ©Hodder Education

11
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 11 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

Learning objective

Use trace tables to systematically debug textbased programs.

Curriculum framework code Student’s Book pages Teacher’s Guide pages Online resources Programming

9P.11 23, 28, 53 25–28, 30–33, 63

Background information

This unit develops students’ knowledge, skills and understanding of programming in Python. Students learn how to write programs to include sequence, selection and count-controlled iteration. They learn how to store more than one item in an array and how to access this information within a program. They learn how to structure count-controlled iteration and arrays in pseudocode. They learn how to create and use a trace table to track a variable effectively through a program as a form of test to find and fix errors. They learn about the different types of errors that can occur in a program and how to find and fix them using trace tables, error messages and test plans.

In preparation for this unit, students should have access to a text-based programming application; the content of this unit has been developed using Python.

Prior knowledge

Students should already be familiar with basic programming in Python from Stages 7 and 8; in particular, how programs can be developed using sequence and selection with the use of input, output, variables and if… elif… else. Where this is not the case, students may require additional guidance when developing programs in Python.

©Hodder Education

9.1.3 Worksheet 4 9.1.3 Worksheet 5 9.1.4 Worksheet 6

Prior to starting this unit, students should already be able to: l develop a Python program using an iterative process l follow and understand an algorithm presented as pseudocode l explain and use the rules AND, OR and NOT to create logic within an algorithm l follow flowcharts and pseudocode algorithms that use conditional statements l predict the outcome of algorithms that use pseudocode l create a Python program that uses conditional statements l create a program in Python that uses a range of different data types l develop a Python program that uses rules involving AND, OR and NOT l decompose a problem into smaller sub-problems to make it easier to solve l identify and describe the data types in a Python program l develop and apply a test plan to ensure that a Python program or algorithm works correctly.

Cambridge learner attributes

Cambridge students are encouraged to display these attributes in every lesson. The tasks in the Student’s Book are designed to support these attributes, e.g. through partner and group work; through peer evaluation; and through independently thinking through a problem even if the outcome is not as expected.

12
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 12 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

9.1 Presenting choices: Combining constructs

Some specific examples for this unit are given below.

Responsible through discussion; when students explore how to develop an algorithm as pseudocode and develop a program to act as a chatbot, they show that they can work collaboratively with others in a respectful and responsible manner. They give other students the opportunity to express their opinions during discussion.

Innovative in the ‘Final project’; students apply the skills they have developed using Python, including the use of arrays, count-controlled iteration and string manipulation, to produce innovative solutions to the problems in the ‘Scenario’. Students are encouraged to develop their chatbot program in Python and test it iteratively by developing and applying a test plan with a range of test data.

Confident in the ‘Practise’ tasks and ‘Final project’; students follow and edit pseudocode and Python, and become more confident in writing program code in Python, including using arrays and countcontrolled iteration. They explore how different Python syntax can be applied in a confident and

expressive way to solve problems presented to them in the ‘Scenario’.

Engaged in tasks across the unit; students develop new skills related to the development of textbased programming in Python and pseudocode. The use of a range of program code will ensure engagement and enquiry in the practical elements of this unit of work.

Reflective through regular discussions with a partner, a small group or as a class about what they have learned; students predict what the pseudocode or programs will do or share thoughts on how to develop a program further. In the ‘Evaluation’, students review each other’s final solution to the ‘Scenario’. Across the unit, students reflect on their work, e.g. they have the opportunity to evaluate the impact of using an iterative process for program development and they develop and apply test plans. Students are encouraged to use the feedback from their tests to make improvements to their work.

©Hodder Education

13
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 13 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

UNIT 9.1 LESSON 1

Student’s Book pages 8–15

l G et started!

l Warm up l Scenario

Boost online resources

l 9.1.1 Worksheet 1

l 9.1.1 Worksheet 1 Answers*

l 9.1.1 Worksheet 2

l 9.1.1 Worksheet 2 Answers*

l Chatbots

l Data types and collecting variable data

l activityChatbotV1(Teacher).py* l activityChatbotStretch(Teacher).py*

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9P.02 Identify and describe data types in text-based programs, including integer, real, character, string and Boolean.

9CT.03 Know how to create algorithms using flowcharts and pseudocode.

Keywords

©Hodder

Success criteria for students

I can identify and describe data types in Python programs, including integer, real, character, string and Boolean.

I can create algorithms using flowcharts and pseudocode.

Flashcards for the following keywords are available in the Boost online resources: l chatbot l machine learning l character l cast l test plan l f lowchart l data type l integer l pseudocode

l rule-based chatbot l program

l real l naming convention l evolving l algorithm l f loat l camelCase l ar tificial intelligence (AI) l s tring l concatenation l snake_case

14 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 14 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample
Education

9.1 Presenting choices: Combining constructs

Starter

Get started! (Student’s Book page 8)

l Read the ‘Get started!’ box with the class. Students, in pairs, should take turns to think of an object and the other student should ask 20 questions that can be answered 'yes' or 'no' to guess the object. It is important for the questions to be ‘yes’/‘no’ style to narrow down the object being guessed and link to how selection works.

l Discuss the use of questions to help to solve a problem:

– When might the answers to a series of questions be used to find a solution? Examples may include a series of medical questions to find the correct diagnosis; an interview with a job applicant to find out whether they are suitable for a role; an interview with a suspected to find out whether they are guilty or innocent.

– Why is more than one question important? A question can lead into another based on the answer; more than one question may be required to ensure that the correct solution is reached – for example in the medical scenario where a series of questions around symptoms is important to help with the diagnosis and to choose the correct next steps.

l Read the ‘Did you know?’ box with the class to introduce what a chatbot is and where students may have met one before.

Warm up (Student’s Book page 9)

l Read the ‘Warm up’ box with the class.

l Discuss with students how the answers to questions help them to make decisions in different scenarios. Refer to the flowchart in the box to illustrate a series of questions that lead from one to another to help to make a decision.

l Ask students to use paper or flowchart software such as https://app.diagrams.net to draw a flowchart for choosing a topping for a pizza. Encourage students to consider the questions that need to be asked and how they should be asked clearly, e.g. Would you like pepperoni, ham and pineapple, or vegetarian?

15
No No IF selection == 1 IF selection == 2 OUTPUT Vegetarian pizza OUTPUT Pepperoni pizza OUTPUT Ham and pineapple pizza Yes Yes Start OUTPUT "Add 1 for pepperoni, 2 for ham and pineapple or 3 for vegetarian" selection = INPUT 369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 15 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder Education

Scenario (Student’s Book page 10)

l Read the ‘Scenario’ with the class. Remind students that they explored selection in Stage 7 in flowcharts and in Stage 8 in Python.

l Discuss how this unit will allow students to develop their Python skills further, to create a program that acts as a chatbot to help them when selecting options or areas of study to continue.

Do you remember? (Student’s Book page 11)

As a class, review the concepts outlined in this box. Revisit any concepts with students where necessary.

Activity notes and answers

Chatbots

Learn (Student’s Book page 11)

l Read the ‘Learn’ box as a class to highlight the difference between the two types of chatbots.

l Focus on rule-based chatbots and how they link with the type of chatbot program students will create.

l Encourage discussion around students’ experiences with chatbots, e.g. using a chatbot to guide them when deciding on a new clothes item or song to listen to.

l Check that students understand the difference between a rule-based chatbot and a chatbot with artificial intelligence.

Practise (Student’s Book page 12)

1 Encourage students to discuss the difference between rule-based and artificial intelligencebased chatbots and which is more suited to development in Python.

2–3 Students should work in pairs find out about retail companies that have chatbot-style support; they should look at the questions in the ‘Practise’ box to support their reviews. Two examples of retail companies are:

– H&M: www2.hm.com/en_gb/customer-service/contact.html

– Nivea: www.nivea.com.au/highlights/sun-chat

Encourage students to discuss the chatbots they found and the similarities and differences between them. Ask questions to guide the discussion, e.g.:

– How do the chatbots start?

– Are there any questions that more than one chatbot uses?

– How do the questions flow into one another?

Answers

1

Rule-based chatbot: A chatbot that asks a set of questions that the user answers.

Artificial-intelligence chatbot: A chatbot that has the ability to learn and develop its own programming from the experiences it encounters.

2–3 The answers below are based on chatbots for the two retail companies H&M and Nivea.

H&M

a To support customers.

b Customers over 18.

c An introduction that states that there is no one available to chat but that the chatbot can help with frequently asked questions, and if it can’t answer the question it can provide contact details of a person who can.

d Simple layout and very clear about its capabilities to allow the user to know what to expect.

16
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 16 31/12/22 8:42 AM f-0229-MAC /103/HO02751/work/indd Sample
©Hodder Education

9.1 Presenting choices: Combining constructs

Nivea

a To offer customers product recommendations and insightful tips and tricks.

b Customers who use skin products.

c It uses images to start the customer’s selection process.

d The images are clear and easier to understand than reading questions; very visual compared with the H&M textual chatbot.

Data types and collecting variable data

Learn (Student’s Book page 12)

l Start by recapping the learning from previous stages where students have used data types. Ask students to share their knowledge and use of data types, e.g. using a string with quotation marks around it or an integer (a whole number).

l Read the ‘Learn’ box as a class. Highlight the different data types available in Python, and that the ‘character’ data type is not used in Python, as a string can hold a single character.

l Focus on the impact on the program when the data type is not set as an integer, and that adding two strings together means just placing them side by side instead of using addition.

l Demonstrate using Python the effect of using input() with and without int() using the examples in the ‘Learn’ box.

l Check that students understand that a ‘real’ data type is the same as a ‘float’, and when programming in Python they need to use ‘float’ to define the data type: float()

Practise (Student’s Book page 15)

1–2 Students should work in pairs to discuss what the flowchart algorithm is going to do and where the variables are. They should write all the variables in a table to plan the variables and the data types to use when writing the program.

3 Students should use their plans and the flowchart to create the pseudocode for the algorithm, remembering the key characteristics: uppercase for START, STOP, INPUT, OUTPUT; selection key areas, e.g. IF, THEN, ELSE; and the use of indentation. Encourage students to compare the pseudocode and flowchart to check they have covered all areas.

4 Once the students have planned the algorithm in pseudocode, they need to use a Python editor to create the program to match. When combining text with variable content in outputs, remind students about using quotation marks around the text output and a comma in between the text and the variable name. Remind students to save their program as activityChatbotV1.py.

5 Remind students that they should structure a test plan using a table like the ones they used in previous stages, e.g.:

Test Test data

Expected outcome Pass/fail

6–7 Ensure that students discuss the different data types and how the variable name is just as important as the data type.

Answers

1 The program starts by defining two variables: adults as False and cost as 7.95. The user is asked to enter an activity and the answer stored in the variable activity. The user is asked their age and the answer stored in the variable age. If the age is greater than or equal to 18, then the variable adult is changed to True. If the variable adult is True, then the variable cost is changed to 9.50. The program will then output As you are ‘age’ it will cost you ‘cost’ to go ‘activity’.

17
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 17 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

2 Variable name

adult Boolean cost Float or Real activity String age Integer

3 For example:

START

adult = False cost – 7.95

activity = INPUT “Enter the activity” age = INPUT “Enter your age”

IF age >= 18 THEN adult = True

ENDIF

IF adult == True THEN cost = 9.50

ENDIF OUTPUT “As you are”, age, “it will cost you”, cost, “to go”, activity

STOP

4 For the completed program, refer to activityChatbotV1(Teacher).py

5 Each student’s test data will be different depending on the day and activities they add when prompted. Here is an example test plan.

TestTest data

1activity = swimming age = 19

Data type

Expected outcome

Pass/fail

As you are 19 it will cost you 9.50 to go swimming Pass

6–7 Variables and data types can help when creating the program code. Planning the variables and data types can help the programmer when writing the program code. If it is created correctly with the correct data types defined, then the program will run as expected.

©Hodder Education

E xamples of data types and which data type is not used in Python are: – string example: "string"

– integer example: 1

– float/real example: 0.5

– character is not used in Python

– Boolean example: Yes/ No

Review

l Provide students with 9.1.1 Worksheet 1. Ask them to read the descriptions and write the Python code to match the variable and data type required.

l For answers, refer to 9.1.1 Worksheet 1 Answers

18
SECONDARY COMPUTING 9 TEACHER'S
CAMBRIDGE LOWER
GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 18 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

9.1 Presenting choices: Combining constructs

Homework

l Provide students with 9.1.1 Worksheet 2 and ask them to highlight where the data type needs to be defined, identify the data type required and write out the correct Python program code.

l For answers, refer to 9.1.1 Worksheet 2 Answers

Differentiation

Chatbots

Stretch: There is an opportunity for students to present their findings to tasks 2–3 to the rest of the class. This allows them to showcase their understanding and support others with their findings.

Support: It may benefit some students to identify similarities and differences. Ask students to think about how the chatbot communicates with the customer, and to decide which chatbot they feel is better and why, e.g. The use of images on the Nivea chatbot means that the customer is able to make a selection based on the visual options. The H&M chatbot is text-based and relies on the user adding a question that the chatbot understands and is be able to answer.

Data types and collecting variable data

Stretch: There is an opportunity for students to add to the pseudocode and chatbot program by considering how to make this program feel more like a chatbot. A chatbot would have more of a userfriendly start to the program. Ask students to consider how the program is presented to the user.

START

OUTPUT “Let me help you find out the cost of your chosen activity”

OUTPUT “I will need to know your chosen activity and age to help you further”

adult = False cost – 7.95

activity = INPUT “Enter the activity” age = INPUT “Enter your age”

IF age >= 18 THEN adult = True

ENDIF

©Hodder Education

IF adult == True THEN cost = 9.50

ENDIF

OUTPUT “As you are”, age, “it will cost you”, cost, “to go”, activity

STOP

For an example solution, refer to activityChatbotStretch(Teacher).py

Support: It may benefit some students to have additional support when considering how to combine the output with the contents stored in the variables. Remind students to add commas between the text output for the variables in the print statement. It can be helpful to write the text output sections and the variable names on individual sticky notes and place them together to plan the program code.

19
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 19 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

UNIT 9.1 LESSON 2

Student’s Book pages 16–18

l Developing in iterations

Boost online resources

l 9.1 Presentation

l 9.1.2 Visual 1

l 9.1.2 Worksheet 3

l 9.1.2 Worksheet 3 Answers*

l pizzaChatbotV1(Teacher).py*

l pizzaChatbotV2(Teacher).py* l pizzaChatbotV3(Teacher).py* l pizzaChatbotV2Stretch(Teacher).py*

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9P.06 Use iterative development on Python prototypes to create solutions to problems.

Keywords

Success criteria for students

I can use iterative development on Python prototypes to create solutions to problems.

l iterate/iterative/iteration l trace table 369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 20 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

Starter

l Display 9.1 Presentation slide 1. Ask students to look at the two examples of program code. Explain that the second example is a development of the original program code (the first example).

l A sk students to spot the differences between the two examples. What is the benefit of the change that has been made and why has it been done? The data type is not set in example 1, which means that the program would not run correctly. The other difference is that, in the second example, the three lines of code with the options to choose between have all been included in the input statement. This improves the efficiency of the code as it reduces the amount of code required.

l E xplain that developing in iterations means testing a prototype, reviewing it and developing it to ensure that the final version is as good as possible.

AQ: <this file is not in the folder with the Boost resources>

Sample ©Hodder Education

20 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
Flashcards for the following keywords are available in the Boost online resources: l evolving l user requirements l prototype

9.1 Presenting choices: Combining constructs

l Provide students with 9.1.2 Visual 1 and ask them to write the pseudocode for the selection section of the program. This is the solution.

IF selection == 1 THEN

OUTPUT "Welcome to the women’s store"

ELSEIF selection == 2 THEN

OUTPUT "Welcome to the men’s store"

ELSE

OUTPUT "Welcome to the children’s store"

ENDIF

Activity notes and answers

Developing in iterations

Learn (Student’s Book page 16)

l Read the ‘Learn’ box as a class and recap the iterative process introduced in Stage 8 and the importance of a prototype.

l Focus on the development of a chatbot program from pseudocode through to program code.

l Highlight the link to software development and the importance of testing and reviewing in the development of a product.

l Check whether students understand that, before fully launching it, the prototype needs to be tested and reviewed using an iterative approach to develop it in stages until a fully functioning final product has been created.

Practise (Student’s Book page 18)

1 Encourage students to discuss why it is better to develop, test and review in iterations. They can write the program requirements and pseudocode on paper or type them into a word-processed document. They should produce a table showing the variables and data types they identify in the pseudocode.

Variable Data type

2 Students need access to a Python editor to create the program code to match the pseudocode. Encourage them to consider the data types and refer to their answers to task 1 to guide the program development. Remind them to save their program as pizzaChatbotV1.py. Testing should focus on ensuring that the program is functional and fulfils the program requirements identified in task 1.

3 The additional option will require the use of an extra elif and appropriate output, e.g. another pizza option to select from. The input statement also needs editing to include '4' as a choice. Students should make the changes and save their programs as pizzaChatbotV2.py.

Answers

1 a Developing in iterations allows the programmer to test and gain feedback from others, which they can use to help develop the program code further. Each iteration enables the program to be developed towards the final prototype.

21
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 21 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

b The chatbot needs to: – output the options for the user to select from – allow the user to select their chosen pizza – output which pizza has been ordered.

c Here is an example pseudocode algorithm.

START

OUTPUT "Welcome to our pizza shop"

OUTPUT "Please select from one of the following toppings"

OUTPUT "1 for pepperoni"

OUTPUT "2 for ham and pineapple"

OUTPUT "3 for no toppings"

INPUT selection

IF selection == 1 THEN

OUTPUT "Pepperoni pizza ordered"

ELSEIF selection == 2 THEN

OUTPUT "Ham and pineapple pizza ordered"

ELSE

OUTPUT "Margherita pizza ordered"

STOP

2 For a solution, refer to pizzaChatbotV1(Teacher).py

3 For a solution, refer to pizzaChatbotV2(Teacher).py

Review

l A sk students to look at pizzaChatbotV2.py and to consider how they could reduce the number of lines of code used to present the inputs to the use. They should then to edit the program to reduce the number of lines of code, where possible, and save this version as pizzaChatbotV3.py

l The output text could be reduced further by placing it into the input line of code.

©Hodder Education

l For a solution, refer to pizzaChatbotV3(Teacher).py.

Homework

l Provide students with 9.1.2 Worksheet 3 and ask them to look at the program code following on from the pizza-chatbot program. The worksheet asks them to describe the developments needed based on the feedback received.

l For answers, refer to 9.1.2 Worksheet 3 Answers

22
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 22 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample

9.1 Presenting choices: Combining constructs

Differentiation

Developing in iterations

Stretch: There is an opportunity for students to develop the program further in task 3 to allow users to choose between more pizza types by adding elif lines of code that match additional input options, e.g. offering the user an additional option: ‘5 for Vegan’. For a solution, refer to pizzaChatbotV2Stretch(Teacher).py

Support: It may benefit some students to have a demonstration of how the program is working in task 2. Ask one student to answer the question and hold up their option number and another student to hold up the pizza selection they have made, e.g. Student 1 holds up number 1 as the pizza selection they would make, and student 2 holds up either a picture of a pepperoni pizza or the words to show the order. This will aid understanding of what the program code is doing when it is run.

©Hodder Education

23
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 23 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample

UNIT 9.1 LESSON 3

Student’s Book pages 19–23

l Code tracers

Boost online resources

l 9.1 Presentation

l 9.1.3 Worksheet 4

l 9.1.3 Worksheet 4 Answers*

l 9.1.3 Worksheet 5

l 9.1.3 Worksheet 5 Answers*

l FoodSelectionChatbot.py

l FoodSelectionChatbotV2(Teacher).py*

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objectives

9P.11 Use trace tables to systematically debug text-based programs.

Keywords

Success criteria for students

I can use a trace table to check the flow of a variable through an algorithm and a Python prototype.

Flashcards for the following keywords are available in the Boost online resources: l f lowchart l selection l pseudocode l integer l variable

l s tring l trace table l truth table l dr y run l criteria

Sample

Starter Display 9.1 Presentation slide 2. Ask students to look at the program code and consider how they would know where an error is located if it is not an error in the syntax, e.g. How can you check the contents of a variable as it moves through the program?

l The variable can be checked by tracking it through each line of code. This can help to find and fix errors and check that the program works as expected.

l The error is on line 7, where the variable name has been entered incorrectly. The error would not present unless that option was selected.

24 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 24 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
©Hodder Education

Presenting choices: Combining constructs

Activity notes and answers

Code tracers

Learn (Student’s Book page 19)

l Read the ‘Learn’ box as a class to highlight how to create and use a trace table. Focus on the column headers in the table and how to add to these to include specific details relating to the algorithm or program code, e.g. the variable name or the conditional statement used in selection.

l Using the example pseudocode, ensure that students can see where the column headers have been edited with the variable name and conditional statement and how the line numbers help to document each step in the algorithm or program.

l Check students understand that whenever an update is made to a variable, it is added to the trace table next to the relevant line number.

Practise (Student’s Book page 23)

1–2 Provide students with the program code FoodSelectionChatbot.py. Students should use the program code to complete a trace table for each input. They need to create the trace table using word-processing software. The trace table will generate an error, as all answers are outputting the same. This is the aim of the task: to find where the error is. Encourage students to complete the trace table even if they locate the error early on, as this helps to highlight the importance of trace tables.

3 Students should develop and correct the program code once they have identified the error. Ensure they save it as FoodSelectionChatbotV2.py.

4 Students should complete the trace tables again for the same four inputs used previously to check that the error has been fixed. It is important that students understand what they expect to see as the output, and discussion around this can aid understanding, e.g. if food selection 1 is added, then the expected output would be ‘If you like Pasta, look for Italian restaurants’.

5 Encourage students to discuss what integer and Boolean data types are. If required, remind them that an integer is a whole number and that Boolean data is either True or False and is generated by selection. Students should use this information to annotate their trace tables, either in writing or using word-processing software.

6 Encourage students to consider how they can use a trace table when planning their ‘Final project’, e.g. ask students how they can use a trace table to check a program.

25
9.1
Answers 1 a Line Variable ConditionConditionConditionCondition Output food food == 1food == 2food == 3 else 1 What type of food would you like for tea? 21 3 False 5 False 7 False 9 True 10 I am sorry I do not recognise that number! 369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 25 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder
Education

b Line Variable ConditionConditionConditionCondition Output

food food == 1food == 2food == 3 else 1

What type of food would you like for tea? 22 3 False 5 False 7 False 9 True 10

I am sorry I do not recognise that number!

c Line Variable ConditionConditionConditionCondition Output

food food == 1food == 2food == 3 else 1

What type of food would you like for tea? 23 3 False 5 False 7 False 9 True 10

I am sorry I do not recognise that number!

d Line Variable ConditionConditionConditionCondition Output food food == 1food == 2food == 3 else 1 What type of food would you like for tea? 24 3 False 5 False 7 False 9 True 10

©Hodder Education

I am sorry I do not recognise that number!

2 The error is that whatever the input, the output is always ‘I am sorry I do not recognise that number!’. The conditional statements are all false, and only the else is true. The error is in the input as it is not being stored as an integer. The program code needs to be edited to include the int() code.

3 For a solution, refer to FoodSelectionChatbotV2(Teacher).py.

26
TEACHER'S
CAMBRIDGE LOWER SECONDARY COMPUTING 9
GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 26 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample

If

If you like Chicken Tikka, look for Indian restaurants

27
9.1 Presenting choices: Combining constructs 4 Input = 1 Line Variable ConditionConditionConditionCondition Output food food == 1food == 2food == 3 else 1 What type of food would you like for tea? 21 3 True 4
you like Pasta, look for Italian restaurants Input = 2 Line Variable ConditionConditionConditionCondition Output food food == 1food == 2food == 3 else 1 What type of food would you like for tea? 22 3 False 5 True 6 If you like Noodles, look for Chinese restaurants Input = 3 Line Variable ConditionConditionConditionCondition Output food food == 1food == 2food == 3 else 1 What type of food would you like for tea? 23 3 False 5 False 7 True 8
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 27 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
Education
©Hodder

Input = 4

Line Variable ConditionConditionConditionCondition Output food food == 1food == 2food == 3 else 1

type of

like for

I am sorry I do not recognise that number!

5 The integer is where the numbers 1, 2, 3, 4 are input and stored in the variable ‘food’. The Boolean data type is the output to each conditional statement if, elif and else.

6 Trace tables can be used to check the content of variables through a program to make sure that the program works as expected and to find any errors that need to be debugged.

Review

l Provide 9.1.3 Worksheet 4 and ask students to look at the Python code and complete the trace table.

l For answers, refer to 9.1.3 Worksheet 4 Answers

Homework

l Provide 9.1.3 Worksheet 5. Ask students to complete the trace table for the Python program.

l For answers, refer to 9.1.3 Worksheet 5 Answers.

Differentiation

Code tracers

Stretch: There is an opportunity for students to justify why an integer is used instead of a string for the input, following task 2, e.g.:

An integer means that the input from the user can be compared easily in the conditional statements; if the input is a string, it could be entered with or without uppercase letters or spelled incorrectly, which could result in the program producing the wrong output.

Support: It may benefit some students to talk through the program in task 1a, using a pen and paper or whiteboard to write down the values stored in the variables and document where and when they change. Working through the first example in this way should give students the confidence to work through the remaining values with a partner.

28
LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
CAMBRIDGE
What
food would you
tea? 24 3 False 5 False 7 False 9 True 10
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 28 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

9.1 Presenting choices: Combining constructs

UNIT 9.1 LESSON 4

Student’s Book pages 23–28

l Error processing

Boost online resources

l Trace templates.docx

l 9.1.4 Worksheet 6

l 9.1.4 Worksheet 6 Answers*

l 9.1.4 Worksheet 7

l 9.1.4 Worksheet 7 Answers*

l StudentScoreChatbot.py

l StudentScoreChatbotV2(Teacher).py*

l StudentScoreChatbotV3(Teacher).py*

l StudentScoreChatbotV4(Teacher).py*

l 9.1.4 Visual 2

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9P.06 Use iterative development on software prototypes to produce solutions to problems.

9P.10 Identify a range of errors, including syntax, logic and runtime errors.

9P.11 Use trace tables to systematically debug text-based programs.

Success criteria for students

I can use iterative development on Python prototypes to create solutions to problems.

I can identify and describe a range of errors, including syntax, logic and runtime errors.

I can use a trace table to check the flow of a variable through an algorithm and a Python prototype.

Keywords

Flashcards for the following keywords are available in the Boost online resources:

l logic error

l syntax error

Starter

Sample

l conditional operator l conditional statement

l A sk students to discuss with their partners the ways in which they have found errors in program code they have created in previous stages. Encourage students to consider how easy it is to find and fix errors, e.g. a message is displayed to show which line an error is on, or testing shows that the program output is not as expected.

l A sk students to recall what trace tables are used for: e.g. a trace table is used when creating an algorithm for following a variable from the start of an algorithm through to the end, and shows where it is input, processed and output.

29
l runtime error 369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 29 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
©Hodder Education

l Share 9.1.4 Visual 2 with students and ask what they can learn from this program-error example. (The error generated is a syntax error; it is an error in the way the program code has been written. It tells you the error is on line 1 and points out that the error is the bracket following the word ‘print’. The error message helps the programmer debug the program code of syntax errors.)

Activity notes and answers

Error processing

Learn (Student’s Book page 23)

l Start by recapping the learning from the previous lesson, looking at trace tables and how they are used to follow a variable through a program and document how its value changes.

l Read the ‘Learn’ box as a class. Focus on the differences between the three different types of errors that can be produced in a program: syntax, logical and runtime.

l Demonstrate the example to show the class how the trace table is completed from the pseudocode example. Emphasise how this trace table can identify the logical error and how the pseudocode can be adjusted to fix it.

l Check that students understand the differences between logical, syntax and runtime errors.

Practise (Student’s Book page 28)

1 a Provide students with StudentScoreChatbot.py. Explain that running the program will provide with guidance on the syntax error.

b Remind students to save the updated program as StudentScoreChatbotV2.py

2 Students need to create trace tables for this task either electronically or on paper. The inputs are provided, and students need to create four trace tables to test the program with a range of inputs.

3 a E xplain to students that they need to use the trace tables to identify a logical error and annotate where they find the error.

b Remind students to save the updated program as StudentScoreChatbotV3.py

4 a Students need to recreate the trace tables they used in task 2, and then compare the completed trace tables to find the differences and see where the error is located and the impact it has on the output. Explain that they now need to use the trace tables to identify a runtime error, and discuss where the error is found.

b Remind students to save the updated program as StudentScoreChatbotV4.py.

5 Encourage students to discuss the different ways in which they identified the errors, how the Python platform helped and where a trace table helped. Explain that using trace tables is a process available to programmers to help find and fix errors. Encourage students to discuss the benefits of using trace tables. Answers 1

30
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
For
2 a Line Variable ConditionConditionConditionCondition Output score score >= 90 score <= 51 and score <=
score >= 20
else 2 95 3 True 4
5
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 30 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder Education
b
a solution, refer to StudentScoreChatbotV2(Teacher).py
89
and score <= 50
You are working at a Distinction level.
Keep the focus on new subject areas.

9.1 Presenting choices: Combining constructs

b Line Variable ConditionConditionConditionCondition Output

score score >= 90 score <= 51 and score <= 89 score >= 20 and score <= 50 else 2 15 3 False 6 True 7

You are working at a Merit level. 8

You are doing well. Focus on revision techniques.

c Line Variable ConditionConditionConditionCondition Output

score score >= 90 score <= 51 and score <= 89 score >= 20 and score <= 50 else 2 25 3 False 6 True 7

You are working at a Merit level. 8

You are doing well. Focus on revision techniques.

d Line Variable ConditionConditionConditionCondition Output

score score >= 90 score <= 51 and score <= 89 score >= 20 and score <= 50 else 2 80 3 False 6 True 7

©Hodder Education

You are working at a Merit level. 8

You are doing well. Focus on revision techniques.

3 a The logical error is with the second conditional statement as it is set to less than or equal to 51 and less than or equal to 89. This causes the conditional statements to be either True or False at incorrect times.

b For a solution, refer to StudentScoreChatbotV3(Teacher).py

31
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 31 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample

working at a Distinction level.

focus on new subject areas.

have not passed this assessment.

one-toone time would help with looking at content.

32 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 32 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
Education
4 a Trace table with input = 95. Line Variable ConditionConditionConditionCondition Output score score >= 90 score >= 51 and score <= 89 score >= 20 and score <= 50 else 2 95 3 True 4 You are
5 Keep the
Trace table with input = 15. Line Variable ConditionConditionConditionCondition Output score score >= 90 score >= 51 and score <= 89 score >= 20 and score <= 50 else 2 15 3 False 6 False 9 False 12 True 13 You
14 Some
Trace table with input = 25. Line Variable ConditionConditionConditionCondition Output score score >= 90 score >= 51 and score <= 89 score >= 20 and score <= 50 else 2 25 3 False 6 False 9 Traceback error
©Hodder

9.1 Presenting choices: Combining constructs

Trace table with input = 80.

Line Variable ConditionConditionConditionCondition Output

score score >= 90 score >= 51 and score <= 89 score >= 20 and score <= 50 else 2 80 3 False 6 True 7

8

b For a solution, refer to StudentScoreChatbotV4(Teacher).py

You are working at a Merit level.

You are doing well. Focus on revision techniques.

5 The Python editor will not run if there is a syntax error and it will generate an error message that is visible to the programmer, indicating what the problem is. This means that syntax errors can be identified more quickly than logical or runtime errors. The use of trace tables helps to identify any logical or runtime errors as they would not be found without thorough testing.

Review

l Provide students with 9.1.4 Worksheet 6. Ask them to read the scenario and complete the trace table for the prototype Python program to find the logical errors.

l For answers, refer to 9.1.4 Worksheet 6 Answers

Homework

l Provide students with 9.1.4 Worksheet 7. Ask them to complete the sentences with the correct type of error and justify why a programmer should use trace tables.

l For answers, refer to 9.1.4 Worksheet 7 Answers

Differentiation

Error processing

Stretch: There is an opportunity during task 5 for students to present their findings and the process they went through to identify the syntax, logical and runtime errors. This allows students to justify the importance of testing and the benefit of trace tables to this process.

Support: It may help some students to have the trace tables set up ready for them to complete for tasks 2, 3, and 4. Provide students with Trace templates.docx , which has the trace tables set up and the line numbers inserted, to support students with completing these tasks.

33
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 33 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

UNIT 9.1 LESSON 5

Student’s Book pages 28–35

l I teration introduction

Boost online resources

l 9.1 Presentation

l 9.1.5 Worksheet 8

l 9.1.5 Worksheet 8 Answers*

l 9.1.5 Worksheet 9

l 9.1.5 Worksheet 9 Answers*

l forLoopExample.py

l CountdownChatbotStart(Teacher).py*

l I teration in algorithms

l countdown10-1(Teacher).py*

l timesTable(Teacher).py*

l FoodSelectionChatbotV2.py (students’ file from Lesson 3)

l FoodSelectionChatbotV3(Teacher).py*

l FoodSelectionChatbotStretch(Teacher).py*

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9CT.02 Follow flowchart or pseudocode algorithms that use loops.

9CT.06 Understand and use iteration statements, limited to count-controlled loops, presented as either flowcharts or pseudocode.

9CT.07 Predict the outcome of algorithms that use iteration.

9CT.08 Compare and contrast algorithms designed for the same tasks to determine which is best suited to the purpose.

9P.03 Know how to develop text-based programs with count-controlled loops.

Keywords

Success criteria for students

I can follow flowchart or pseudocode algorithms that use loops.

I can explain and use iteration statements with count-controlled loops in either pseudocode or flowcharts.

I can evaluate the processes that are followed to develop programs.

I can compare and contrast two algorithms for the same solution and decide which is best suited to the task.

I can predict the outcome of algorithms that use iteration.

Flashcards for the following keywords are available in the Boost online resources:

l sequence

l for loop

l selection

l loop variable

l execute

l ef ficient

l iterate/iterative/iteration

l count-controlled loop

34 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 34 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

9.1 Presenting choices: Combining constructs

Starter

l Display 9.1 Presentation slide 3. Ask students to read Instruction 1 and follow it (clap their hands once, clap their hands once, clap their hands once).

l A sk students to read Instruction 2 and follow it (clap their hands three times and stop).

l A sk students the difference between the instructions (the instructions are the same, but the second set of instructions asks for the same instruction to be repeated three times, instead of writing the instruction out individually three times).

l E xplain that there are times in programs such as chatbots when instructions or questions need to be asked more than once. The use of a loop can save time for the programmer, as the same instruction is not written out more than once; it is set to run a set number of times.

Activity notes and answers

Iteration introduction

Learn (Student’s Book page 28)

l Read the ‘Learn’ box as a class. Focus on the structure of a count-controlled loop and use forLoopExample.py to demonstrate the code in the ‘Learn’ box, which shows the output and the iteration number.

l E xplain how a count-controlled loop can be used in a chatbot to ask a question more than once, and how selection can be indented inside the for loop. Demonstrate this on the teacher computer.

l Check students understand that a count-controlled loop is used to repeat instructions a set amount of times.

Practise (Student’s Book page 30)

1 Students need the Python program they created in the previous lesson that they saved as FoodSelectionChatbotV2.py Encourage them to consider which lines of code would need to be indented inside a count-controlled loop to allow it to be run twice.

2 Students need to consider where instructions are being repeated to identify where to add a count-controlled loop. Once they have made changes to the program code by adding a count-controlled loop, they need to save their new development iteration as FoodSelectionChatbotV3.py

Answers

1 The question asking the user to input and the selection need to be indented inside a for loop set to run twice.

2 For a solution, refer to FoodSelectionChatbotV3(Teacher).py

Iteration in algorithms

Learn (Student’s Book page 31)

l Read the ‘Learn’ box as a class. Focus on the difference between the flowcharts with and without a count-controlled loop and the pseudocode with and without a count-controlled loop.

l Discuss how a count-controlled loop can help to reduce the number of lines of code, and how this makes the code more efficient.

l Check that students understand how a count-controlled loop is represented in the flowchart and pseudocode.

Sample ©Hodder Education

35
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 35 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

GUIDE

Practise

(Student’s Book page 34)

1–2 Students should work in pairs to discuss each pseudocode example. Encourage students to talk through each pseudocode example to identify the flow, e.g. identifying that this is an example of two algorithms that have been designed for the same output.

3 Students should work in pairs. Remind them that comparing is looking for similarities and/or differences, and contrasting involves comparing to find the differences.

4 Remind students that efficiency in program code is defined by the lack of repetition of lines of code and the effective use of selection and iteration.

5 Students should create a variable and data-type table in word-processing software or in writing. Remind them that they are focusing on pseudocode example 2 with the countcontrolled loop.

6 Students should create a program that matches pseudocode example 2 with the countcontrolled loop and save it as CountdownChatbotStart.py. Remind them of the importance of the colon and indentation in writing the for loop.

7 Students should use word-processing software or on paper. Remind them of the importance of the column headings and how these are linked to the variables being used; ‘i’ for counting the iterations and ‘countdown’ for storing the number/integer.

8 Encourage students to discuss in pairs how the use of a count-controlled loop could benefit a user at the start of a program. Encourage discussion with the following questions: – When do you know that a chatbot or program has started? – Would a countdown help to get you ready to answer questions?

Answers

1 The prediction should be that both the program outputs would count down from 3 to 1 and then say ‘Let’s start’, with a 1-second delay between each output.

2 A chatbot could use a loading-style countdown to the first question as a loading start or to get the user ready to start talking to the chatbot.

3 Pseudocode example 1 imports the 'time' library and sets up a variable called ‘countdown’ that is output and then reduced by 1, output and reduced by 1, output and reduced by 1, and then outputs ‘Let’s start’. The output displayed is: ‘3, 2, 1. Let’s start’.

Pseudocode example 2 imports the ‘time’ library and sets up a variable called ‘countdown’. A count-controlled loop is used to iterate over the output and reduction of the variable value by 1. The loop will iterate three times and then output the text ‘Let’s start’.

Similarities

Both algorithms produce the same output

Both algorithms use the ‘time’ library

Differences

Algorithm 1 uses only sequence; algorithm 2 uses a count-controlled loop

The countdown has an initial value of 3 in algorithm 1 and 4 in algorithm 2

Algorithm 2 includes a count variable ‘i’

4 The second example is more efficient, as the count-controlled loop iterates over two instructions, reducing the number of lines of code. The first example takes longer to create as more lines of code are needed.

36
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 36 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

8 For example: A countdown is a good way to start a program or chatbot. It acts like an introduction before the user starts to play a game or answer questions.

– When do you know that a chatbot or program has started? Some chatbots go straight into ‘Hello’, and if the user does not answer quickly there is a timer that prompts them to answer or check that they are still there. Having a structured start could help users.

– Would a countdown help to get you ready to answer questions? At the start, it may help users to know when the questions are about to begin by giving them a visual prompt with a countdown.

Review

l Provide students with 9.1.5 Worksheet 8 and ask them to complete the questions about countcontrolled iteration. Students need access to a Python editor to complete the tasks.

l For answers, refer to 9.1.5 Worksheet 8 Answers and timesTable(Teacher).py

Homework

©Hodder Education

l Provide students with 9.1.5 Worksheet 9 and ask them to look at the pseudocode and identify the variables, data types, output from an input, and how the number of iterations is defined in this program.

l For answers, refer to 9.1.5 Worksheet 9 Answers.

37
9.1 Presenting choices: Combining constructs 5 Variable Data type countdown integer i integer 6 For a solution, refer to CountdownChatbotStart(Teacher).py. 7 For example: Line Variable Variable Output i countdown 4 3 5 0 6 3 5 1 6 2 5 2 6 1 9 Let’s start
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 37 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

Differentiation

Iteration introduction

Stretch: There is an opportunity following task 2 to add to the program a ‘thank you’ line of code that is run after the count-controlled loop has been completed.

For a solution, refer to FoodSelectionChatbotStretch(Teacher).py.

Support: It may benefit some students to have additional support in task 2 when creating the count-controlled loop. Write down the possible outputs for the food selection on pieces of paper and give them to one student. Ask the student to act as the chatbot and to ask you for your food selection; then give your choice and have the student hold up the piece of paper with the output that is linked to the answer. Repeat this process to demonstrate the count-controlled loop. Discuss with students how they would know how many times to ask for the food selection (the number set on the for loop). Also ask how they knew which piece of paper to hold up (they made the decision based on the food selection; this is what selection does).

Iteration in algorithms

Stretch: There is an opportunity following task 6 for students to edit the program code to increase the countdown to start from 10 and finish at 1.

For a solution, refer to countdown10-1(Teacher).py

Support: Some students may need additional support in task 7 when completing the trace table. They may benefit from a written, on paper or whiteboards, that shows how the contents stored in the variables change. Highlight that the variable ‘i’ is increasing with each iteration starting from 0.

Sample ©Hodder Education

38
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 38 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

9.1 Presenting choices: Combining constructs

UNIT 9.1 LESSON 6

Student’s Book pages 35–38

l I terations and arrays

Boost online resources

l 9.1 Presentation

l 9.1.6 Worksheet 10

l 9.1.6 Worksheet 10 Answers*

l 9.1.6 Worksheet 11

l 9.1.6 Worksheet 11 Answers*

l iceCreamFlavoursChatbot(Teacher).py* l rainbowColoursChatbotV1(Teacher).py* l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9CT.02 Follow flowchart or pseudocode algorithms that use loops.

9CT.07 Predict the outcome of algorithms that use iteration.

9P.01 Explain the purpose of a one-dimensional array.

9P.03 Know how to develop text-based programs with count-controlled loops.

9P.04 Know how to access data from an array using a text-based language.

Keywords

Success criteria for students

I can follow flowchart or pseudocode algorithms that use loops.

I can predict the outcome of algorithms that use iteration.

I can identify and explain the purpose of a onedimensional array.

I can develop a Python program with countcontrolled loops.

I can access data from an array using Python.

©Hodder Education

Flashcards for the following keywords are available in the Boost online resources: l array l list l data item

39
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 39 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

Starter

l Display 9.1 Presentation slide 4. Ask students what a list is and where they have used lists before, e.g. shopping lists, to-do lists, debugging checklists, project-requirement checklists.

l Point out that lists store more than one item, e.g. a shopping list has more than one item for purchase.

l A sk students where, at present, they store items in a Python program (in a variable, and it can store one item).

l A sk students how they have stored multiple items in a Python program before (by creating multiple variables, each with its own name and storing one item).

l E xplain that there is another type of storage that can be used in a program, which is called an array, and another word for this is a list as it can store more than one item.

Activity notes and answers

Iterations and arrays

Learn (Student’s Book page 35)

l Read the ‘Learn’ box as a class. Demonstrate on the teacher computer how to set up an array in Python.

l Focus on how you can use a for loop to iterate through the items in a list.

l Demonstrate how you can use a for loop to add a set number of items to a list.

l Check students understand that a list can store more than one item, compared with a variable, which can store only one item.

Practise (Student’s Book page 37)

1–2 Students should work in pairs to discuss the pseudocode. Use the questions in the ‘Practise’ box to structure the discussion, and encourage students to analyse the pseudocode for the loop and list.

3 Students need to create the program that matches the pseudocode and save it as rainbowColoursChatbotV1.py. Remind students that to add an item to an array they need to ‘append’ it, and that this code needs to be indented in the for loop to allow each answer to be added to the array.

4 Students could document the specific output they expect to see along with the actual output to check that the program works as expected.

5 Encourage students to consider what is stored in the array and how a count-controlled loop is used to access each item in turn to print it out.

Answers

1 a red, orange

b Five times

c The output will be “Your rainbow colours are: Red orange …” followed by the 4 colours the user enters when prompted.

d To break up the inputs and the outputs

e red, orange, yellow, green, blue, indigo, violet

2 For example:

Your rainbow colours are: red orange

40
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 40 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

9.1 Presenting choices: Combining constructs

yellow green blue indigo violet

3 For a solution, refer to rainbowColoursChatbotV1(Teacher).py

4 Students should find that their output prediction in task 2 is replicated when the program is run.

5 The array is used to store all the colours in the program. A count-controlled loop is used to access each colour in turn and print it out.

Review

l Provide students with 9.1.6 Worksheet 10 and ask them to look at the pseudocode to answer the questions and create the Python program.

l For answers, refer to 9.1.6 Worksheet 10 Answers

Homework

l Provide students with 9.1.6 Worksheet 11 and ask them to complete the sentences with the missing words.

l For answers, refer to 9.1.6 Worksheet 11 Answers

Differentiation

Iterations and arrays

Stretch: There is an opportunity in task 1 for students to lead the discussion and demonstrate how to locate the answers for each question, e.g. by using the teacher computer to demonstrate the code to add an item to the array. This allows students to extend their knowledge by explaining the process for answering the questions linked to the pseudocode. Ask students how they would edit the code to allow another colour to be added to the array (increase the number of iterations in the for loop from 5 to 6).

Support: It may benefit some students to work through the questions in task 1 as a class or in a group, to demonstrate together the process of working through each question and identifying where the answers are located, e.g. the content of the array at the start of the program means identifying where the array is defined and what is inside the square brackets.

41
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 41 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

369818_9.1_Camb_LS_CS9_TG_010-064.indd

UNIT 9.1 LESSON 7

Student’s Book pages 38–45

l Developing the chatbot further

Boost online resources

l 9.1 Presentation

l 9.1.7 Worksheet 12

l 9.1.7 Worksheet 12 Answers*

l Pseudocode.docx

l ActivitiesChatbot.py

l ActivitiesChatbotV2(Teacher).py*

l ActivitiesChatbotV3(Teacher).py*

l Keyword flashcard

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9CT.03 Know how to create algorithms using flowcharts and pseudocode.

9CT.09 Combine multiple constructs (sequence, selection, count-controlled iteration) to write algorithms as flowcharts or pseudocode.

9P.01 Explain the purpose of a one-dimensional array.

9P.06 Use iterative development on software prototypes to produce solutions to problems.

Keyword

Starter

Success criteria for students

I can create algorithms using flowcharts and pseudocode.

I can create an algorithm as a flowchart or pseudocode using more than one construct: sequence, selection and count-controlled iteration.

I can identify and explain the purpose of a onedimensional array.

I can use iterative development on Python prototypes to create solutions to problems.

l Display 9.1 Presentation slide 5. Ask students to identify where the program code uses selection and count-controlled iteration. Slide 6 shows the two areas labelled.

l Using slide 6, ask students to identify:

– the input (food = int(input…)

– an output in the program code (print())

– how many times the loop will iterate (two)

Sample ©Hodder

42 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
A flashcard for the following keyword is available in the Boost online resources: l one-dimensional array Page 42 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Education

9.1 Presenting choices: Combining constructs

– the data type the variable is stored as (integer) – which lines of code are displayed before and after the input and selection (print("What type of food would you like for tea?"), print("Thank you for your selections")).

Activity notes and answers

Developing the chatbot further

Learn (Student’s Book page 38)

l Read the ‘Learn’ box as a class. Focus students on understanding the key concepts and how they are demonstrated in a flowchart and pseudocode. It may benefit students to compare the flowcharts and pseudocode throughout the ‘Learn’ box to see how they are developed iteratively.

l Focus on talking through the use of arrays and how the data is accessed from the arrays using the position number.

l Discuss how a program is developed based on the initial requirements, but can be developed iteratively as the program is tested and reviewed.

l Check that students understand the importance of the different programming concepts (sequence, selection and iteration) in the development of any program, and how these enable it to evolve from algorithm to program.

Practise (Student’s Book page 44)

1 Students should consider what additional items could be added to the program’s arrays to expand the program further, and the structure of the additional activity when added to the array. Students need to add a new item to each array.

2 Students need to create the pseudocode for the new development iteration either electronically or on paper. With the addition of more items in the array, students need to consider the selection statements to ensure that there is an output if the user selects 1, 2 or 3 when prompted. Students also need to consider the number of iterations in the for loop, so that all options are displayed to the user.

3 Students need to work in pairs to compare and contrast their pseudocode. They need to create a trace table on word-processing software or paper to test each other’s pseudocode. Remind students that comparing is looking for similarities and/or differences, and contrasting is comparing to show the differences, e.g. ‘both programs have for loops’ is comparing; ‘student 1 has a for loop that iterates twice and student 2 has a for loop that iterates three times’ is contrasting.

4 Students need ActivitiesChatbot.py to develop the program code to add the new activities. Students should not change the main structure of the original program; they are adding the additional array items and additional conditional statements to the program using elif to accommodate the additional items. Remind students to save this as ActivitiesChatbotV2.py

5 a Encourage students to consider how selection would be used to ask further follow-on questions, each depending on the previous answer.

b Students should consider how one-dimensional arrays can be used to provide a list of options for the user to choose between.

43
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 43 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

Answers 1 At least one extra activity needs to be added into each array. 2 Here is one possible solution. 1 START 2

ARRAY water = [Swimming, Canoeing, Windsurfing] 3 ARRAY team = [Hockey, Volleyball, Netball] 4 ARRAY waterNew = [Water polo, Sailing, Paddleboarding] 5 ARRAY teamNew = [Cricket, Beach volleyball, Basketball] 6 OUTPUT "Do you prefer watersports or team games?"

INPUT typeOfActivity

©Hodder Education

9 IF typeOfActivity == "W" THEN 10 OUTPUT "Which of the following watersports do you prefer?" 11 FOR i = 0 to 2 12 OUTPUT i + 1, water[i] 13 OUTPUT "Enter the number of your preferred activity" 14 INPUT activity1 15 OUTPUT "You have chosen" activity1 16 17 IF activity1 == 1 THEN 18 OUTPUT "Why not try" waterNew[0] 19 ELSEIF activity1 == 2 THEN 20 OUTPUT "Why not try" waterNew[1] 21 ELSE 22 OUTPUT "Why not try" waterNew[2] 23 ENDIF 24

OUTPUT "Which of the following team games do you prefer?" 27 FOR i = 0 to 2 28 OUTPUT i + 1, team[i]

OUTPUT "Enter the number of your preferred activity" 30 INPUT activity2

OUTPUT "You have chosen" activity2

44
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
7
8
25 ELSE 26
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 44 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
29
31
Sample
45
3
The
team , Hockey Line ArrayArray Array Array Variable Condition VariableVariable Condition Output waterteam waterNewteamNew typeOf Activity typeOf Activity == "W" i activity2activity2 == 1 2 Swimming Canoeing Windsurfing 3 Hockey Volleyball Netball 4 Water polo Sailing Paddleboarding 5 Cricket Beach volleyball Basketball 6 Do you prefer watersports or team games? 7 team 9 False 32 33 IF activity2 == 1 THEN 34 OUTPUT "Why
try" teamNew[0] 35 ELSEIF activity2
2 THEN 36 OUTPUT "Why
37 ELSE 38 OUTPUT "Why
teamNew[2] 39 ENDIF 40 41 ENDIF 42 STOP 369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 45 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder Education
9.1 Presenting choices: Combining constructs
Students’ comparisons will differ depending on their pseudocode. Each student should consider why they created their pseudocode the way they did, and discuss the similarities and differences. Comparisons should identify similarities and differences; contrasting should back up the similarities and/or differences with specific details, e.g. the position numbers of the array used are different.
trace table below shows one flow through the program using the following inputs:
not
==
not try" teamNew[1]
not try"

activity2activity2 == 1

Which of the following team games do you prefer? 28 0 Hockey 28 1 Volleyball 28 2 Netball 29 Enter the number of your preferred activity 30 1 31 You have chosen Hockey 33 True 34 Why not try Cricket 4 For a possible solution, refer to ActivitiesChatbotV2(Teacher).py

5 a For example: Selection enables the next question a chatbot asks to vary depending on the answer to the previous question. If selection was not used, then the chatbot would always ask exactly the same questions in exactly the same order.

b Each one-dimensional array (list) in this chatbot program stores the different options for a particular type of activity.

Review

l A sk students to consider what would happen if the user did not enter their choice as expected when asked for their preferred activities in their last development of the activities chatbot ActivitiesChatbotV2.py

l Ask: How could the program prototype be developed further in another iteration to ensure that the user receives a message to advise them that they have entered an invalid choice? Students should develop their Python programs and save their development iterations as ActivitiesChatbotV3.py

l Remind students that the user should always be asked to enter their choice as an integer. This will avoid problems with upper/lowercase or misspelling.

l For a solution, refer to ActivitiesChatbotV3(Teacher).py

Homework

l Provide students with 9.1.7 Worksheet 12 and ask them to look at the program code, identify where the key programming concepts are located and answer the questions.

l For answers, refer to 9.1.7 Worksheet 12 Answers

46
LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE Line ArrayArray Array Array Variable Condition VariableVariable Condition Output
waterNewteamNew
Activity typeOf Activity
CAMBRIDGE
waterteam
typeOf
== "W" i
26
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 46 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Education
Sample ©Hodder

9.1 Presenting choices: Combining constructs

Differentiation

Developing the chatbot further

Stretch: There is an opportunity in task 4 for students to share their program development with others in the class and describe how they have arrived at their solution. This gives students the opportunity to showcase their understanding by explaining and justifying their own program development.

Students could also discuss how the program would need to be developed if the chatbot needed to include a new type of sport ‘air sports’ (a new array would need to be created, with ‘air sports’ and additional options added to the program to allow the user to select and output in the same way as the other sport options).

Support: Some students may benefit from receiving the existing pseudocode for task 2, which they can annotate to show the new developments, rather than writing the whole pseudocode algorithm from scratch. Provide these students with Pseudocode.docx .

©Hodder Education

47
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 47 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample

UNIT 9.1 LESSON 8

Student’s Book pages 45–48

l Testing times

Boost online resources

l 9.1 Presentation

l 9.1.8 Worksheet 13

l 9.1.8 Worksheet 13 Answers*

l 9.1.8 Worksheet 14

l 9.1.8 Worksheet 14 Answers*

l TestProgram.py

l TestProgramV2(Teacher).py*

l TestProgramV3(Teacher).py*

l travelChatbotV1.py

l travelChatbotV2(Teacher).py*

l syntaxErrorExample.py

l runtimeErrorExample.py

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9P.08 Know how to develop and apply test plans that include normal, extreme and invalid data.

9P.09 Identify test data that covers normal, extreme and invalid data.

9P.10 Identify a range of errors, including syntax, logic and runtime errors.

Keywords

Success criteria for students

I can develop and apply test plans that include normal, extreme and invalid data.

I can identify test data that covers normal, extreme and invalid data.

I can identify and describe a range of errors, including syntax, logic and runtime errors.

Flashcards for the following keywords are available in the Boost online resources:

l syntax error

l traceback message

l integrated development environment (IDE)

l normal test data

l logic error

l extreme test data

l conditional operator

l invalid test data

l runtime error

Sample ©Hodder Education

48
LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
CAMBRIDGE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 48 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

9.1 Presenting choices: Combining constructs

Starter

l Display 9.1 Presentation slide 7. Ask students to identify the errors in the code. The errors are syntax errors in how the code has been written. There are seven errors within the chatbot code for the ice cream selection program.

l Slide 8 has the seven areas circled.

l A sk students how they know when there is a syntax error – an error in the way the program is written (the program will not run and it generates an error message for the programmer to investigate and fix).

Activity notes and answers

Testing times

Learn (Student’s Book page 45)

l Read the ‘Learn’ box as a class. Focus students on the three different types of errors that can be found in program code. Demonstrate the following programs on the teacher computer to match the Student’s Book examples:

– syntaxErrorExample.py links with the first program code in the ‘Learn’ box

– runtimeErrorExample.py links with the program code in the table in the ‘Learn’ box.

l Discuss how the programmer knows that an error has been found, e.g. the error message that appears at the start for a syntax error, and when it is encountered for a runtime error. Remind students of the lessons containing the trace tables and how they helped to identify logical errors in the conditional statements.

l Check students understand that a syntax error generates an error immediately when you try to run the program, a logical error allows the program to run but will not give the expected outputs, and a runtime error generates a traceback error when the problem line of code is executed in the program.

Practise (Student’s Book page 48)

1 Provide students with TestProgram.py and ask them to identify suitable test data. Encourage them to use a range including normal, extreme and invalid data. It is important that students run the program and complete the test plan, even if they see the errors first. Encourage them to look at the error messages to identify and fix the errors. Students should debug and fix the program code and save it as TestProgramV2.py

2 Ensure that students understand the importance of using a wide range of test data to find and fix the range of possible errors. Check that they understand the benefits of normal, invalid and extreme test data in a test plan.

3 Encourage discussion by asking students to consider which type of error presents itself to the programmer first and why. Which error might be the last type a programmer finds? Why?

4 Emphasise to students that test plans are a process that programmers use to facilitate the development of the program code. Ask them to evaluate the importance of test plans linked with test data and types of errors, e.g. Would a logical error be found without using a full range of test data?

Answers

1 a E xtreme test data does not work on this program as the inputs can be anything. Normal test data would be adding and using pizza toppings, e.g. ham, pepperoni and mushroom. Invalid test data would be an option that had not been added at the start of the program, e.g. ‘sausage’.

Sample ©Hodder Education

49
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 49 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE

b–c This is an example showing test data.

TestTest data

NormalpizzaToppings = ham, pepperoni, mushroom input

Expected outcome Pass/fail

Output as contents of array

Normal decision = Pepperoni Output: You can have double that topping! Fail

Invalid decision = Sausage Not accepted Fail: You can have double that topping!

d For a solution, refer to TestProgramV2(Teacher).py

e

TestTest data

NormalpizzaToppings = ham, pepperoni, mushroom input

Normal decision = Pepperoni

Expected outcome Pass/fail

Output as contents of array

Output: You can have double that topping! Pass

Invalid decision = Sausage Not accepted Pass

2 Testing a program with a wide range of data is essential to help find and fix all types of errors. The different types of test data help to find different types of errors, e.g. the invalid test data highlighted the logical error as it would not have been found in the array. This shows that the error was the comparison operator !=, which should have been ==. This could also have been identified using a trace table.

3 – A syntax error is when the code has been added incorrectly and stops the program running until it is fixed. This type of error is identified first as the program will not run.

– A runtime error is when the program starts correctly but an error is found as the program code is run. This is found through test plans using a range of test data; the program will stop running and the error will be located with a traceback message, including information to help find and fix it.

– A logical error is when the program will run but the output is not as expected if the wrong operator has been used. A trace table would help to find and fix this error as it may be linked with how a conditional statement uses a comparison operator. The other way in which a logical error may be found is through using invalid and extreme test data, as this would test the range of inputs in the program.

4 A test plan is an essential process for a programmer, and without it some errors, such as a logical error, may not be detected. If the prototype program is not tested fully, the final program could be released and not work as it is supposed to.

Review

l Provide students with travelChatbotV1.py and 9.1.8 Worksheet 13. Ask students to run the program to find and fix the errors. The program contains syntax errors, a logical error and a runtime error. Once students have debugged the program and it is error-free, they should save it as travelChatbotV2.py.

l For a solution, refer to travelChatbotV2(Teacher).py and 9.1.8 Worksheet 13 Answers

Sample ©Hodder Education

50
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 50 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

9.1 Presenting choices: Combining constructs

Homework

l Provide students with 9.1.8 Worksheet 14. Ask them to read the words and use them to fill in the gaps, reviewing the different types of errors and test data by adding the correct keyword to each paragraph.

l For answers, refer to 9.1.8 Worksheet 14 Answers

Differentiation

Testing times

Stretch: There is an opportunity in task 1 for students to consider how the program tells the user that the input is invalid, as they are still told to enjoy the pizza, e.g. How could they use else to complete the final lines of code and also move the code on line 14?

For a solution, refer to TestProgramV3(Teacher).py

Support: For task 1, it may benefit some students to discuss the possible inputs that could be used as normal test data, e.g. ask students to select three toppings for the pizza and use these as the normal test data. Explain that there is no extreme test data for this test plan as the toppings array could accept any input. Working through the creation of the test-plan and carrying out the testing with another student can enable discussion and support through this process.

Sample ©Hodder Education

51
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 51 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

UNIT 9.1 LESSON 9

Student’s Book pages 49–52

l G o further

l Challenge yourself

Boost online resources

l RainbowColoursChatbot.docx

l rainbowColoursChatbotV1.py (Students’ file from Lesson 6)

l rainbowColoursChatbotV2(Teacher).py*

l rainbowColoursChatbotV3(Teacher).py*

l stringManipulation.py

l stringManipulation(Teacher).py*

l challengeYourself(Teacher).py*

l stringManipulationExamples.py

l Keyword flashcard

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the worksheets digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9CT.01 Follow, understand, edit and correct algorithms that are presented as pseudocode.

9P.05 Know how to develop text-based programs using string manipulation, including length, uppercase and lowercase.

Keyword

Success criteria for students

I can follow, understand, edit and correct algorithms that are presented as pseudocode.

I can develop Python programs using string manipulation, including length, uppercase and lowercase.

A flashcard for the following keyword is available in the Boost online resources: l s tring manipulation

Starter

l A sk students, in pairs, to write down all the different ways in which they could enter the word ‘Python’, considering upper and lowercase letters, e.g.:

– python

– PYTHON – Python – PYthon

– PYThon – PYTHon – PYTHOn – PyThOn

l A sk students how a chatbot program would know how a user is going to answer a question (there is no way of knowing completely, and the program would not be able to accommodate all possible combinations as an input).

Sample ©Hodder Education

l E xplain that the solution is for the program to change whatever is input into a specific format for the rest of the program to understand, e.g. changing any of the ways of entering ‘Python’ listed above to all lowercase letters (‘python’).

52 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 52 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

9.1 Presenting choices: Combining constructs

Activity notes and answers

Go further (Student’s Book page 49)

1–2 Read the ‘Go further’ box with the class. Focus on what string manipulation is, and when you would use it in a chatbot to allow the input to be stored in one format. Demonstrate the code in the ‘Go further’ box using the file stringManipulationExamples.py to allow students to see the impact each example has on the program code. The pseudocode is from the ‘Iterations and arrays’ section in Lesson 6 for a chatbot that asks the user for colours. Students need access to the rainbowColoursChatbotV1.py file that they created in the same lesson. Encourage them to use pen and paper or to discuss how a user may enter the different colours.

3 Students need RainbowColoursChatbot.docx to annotate the pseudocode to incorporate string manipulation for the user’s input and to output the number of items in the array. Highlight that the output of the number of items in the array is after each input, so will be output during each iteration of the count-controlled loop.

4 Remind students that the aim is for all the inputs in the program to be changed to lowercase, and that after each input the number of items in the array is output too. This means that the additional line of code will be inside the for loop under the input line of code. Students should save the new iteration as rainbowColoursChatbotV2.py

5–6 Students need to think about how to test the program iteration, e.g. if lower() is used, then the test would be to input all the colours in uppercase to see whether the input is changed to lowercase.

Answers

1–2 A user may enter the colours in lowercase, e.g. ‘red’; in uppercase, e.g. ‘RED’; or with an initial uppercase, e.g. ‘Red’.

3 Here is an example of how it may look in pseudocode: START

Use string manipulation to change all inputs to lowercase.

Add a new line of code to output the number of items in the array.

53
FOR i =
TO 4 Add INPUT to ARRAY "Add a colour" ENDFOR OUTPUT "--------------------" OUTPUT "Your rainbow colours are:" FOR each colour in ARRAY rainbow: OUTPUT colour ENDFOR STOP
ARRAY rainbow = [red, orange]
0
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 53 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder
Education

4 For a solution, refer to rainbowColoursChatbotV2(Teacher).py

5–6 Testing needs to include the way in which a user may enter the colours, e.g. ‘YELLOW’, ‘Yellow’ or ‘yellow’.

Here is an example of possible test data is.

TestTest data

Expected outcome Pass/fail

Normal YELLOW yellow Pass

NormalYellow yellow Pass

Normalyellow yellow Pass

Extreme YeLlOw yellow Pass

Extreme YELlow yellow Pass

Extreme yelLOW yellow Pass

Challenge yourself (Student’s Book page 51)

1 A sk students to read individually or in pairs the text in the ‘Challenge yourself’ box. Explain that this is additional code that can be used to combine two arrays in an output.

Students should save their program as challengeYourself.py

2–3 Students need to use word-processing software to create a suitable test plan and consider whether they can include normal, extreme and invalid test data.

Answers

1 For a solution, refer to challengeYourself(Teacher).py.

2–3 Test data would not go beyond normal in this instance as the input would take any words and output them. There could not be anything built into the program to detect whether a name is true or not.

TestTest data

Normal Joe, Sam, Tom Computing, Maths, Science

Review

Expected outcome Pass/fail

Joe likes Computing

Sam likes Maths

Tom likes Science

l Provide students with stringManipulation.py and ask them to complete the code to match each instruction using uppercase, lowercase, initial uppercase and length string manipulation.

l For a solution, refer to stringManipulation(Teacher).py

Homework

Ask students to consider the use of string manipulation and to review the ‘Scenario’ at the start of the unit, ahead of the next lesson when they will start the ‘Final project’. Students should consider the scenario of a program for selecting their options or subject areas and think about how they could use an array for subject options, e.g. they could set up subject options in an array and use string manipulation for selecting the subject to ensure that it matches the way it has been stored in the array.

54
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 54 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
©Hodder Education

9.1 Presenting choices: Combining constructs

Differentiation

Go further

Stretch: Following task 4, students have the opportunity to create a further development iteration of their program by using capitalize instead of lower and observing the difference in output. Note that they should also edit the items in the array so that they begin with an uppercase letter. This may become obvious when they run their program to test it. Students should save their new developments as rainbowColoursChatbotV3.py

For a solution, refer to rainbowColoursChatbotV3(Teacher).py.

Support: Students may benefit from some support in task 2 when they consider how a user may enter the colours. Ask students to choose a colour and write each letter on a separate sticky note in lower and uppercase. They can use the notes to spell out the colour with different combinations of upper- and lowercase letters.

©Hodder Education

55
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 55 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample

UNIT 9.1 LESSON 10

Student’s Book pages 52–54

l Final project

l Evaluation

Boost online resources

l 9.1 Knowledge test

l finalProjectV1(Teacher).py*

l What can you do?

l finalProjectStretch(Teacher).py*

l 9.1 Keywords flashcards

* These files contain completed examples and are provided for teacher reference to support evaluation of student responses to the tasks.

Students need access to IDLE on their devices to complete the Python programming tasks. They also need access to word-processing software, e.g. MS Word, if they are completing the written tasks digitally.

Success criteria

Share the following success criteria at the start of the lesson:

Learning objective

9CT.03 Know how to create algorithms using flowcharts and pseudocode.

9CT.06 Understand and use iteration statements, limited to count-controlled loops, presented as either flowcharts or pseudocode.

9CT.09 Combine multiple constructs (sequence, selection, count-controlled iteration) to write algorithms as flowcharts or pseudocode.

9P.01 Explain the purpose of a one-dimensional array.

9P.02 Identify and describe data types in text-based programs, including integer, real, character, string and Boolean.

9P.03 Know how to develop text-based programs with count-controlled loops.

9P.04 Know how to access data from an array using a text-based language.

9P.05 Know how to develop text-based programs using string manipulation, including length, uppercase and lowercase.

9P.06 Use iterative development on software prototypes to produce solutions to problems.

9P.07 Evaluate the processes that are followed to develop programs.

Success criteria for students

I can create algorithms using flowcharts and pseudocode.

I can explain and use iteration statements with count-controlled loops in either pseudocode or flowcharts.

I can create an algorithm as a flowchart or pseudocode using more than one construct: sequence, selection and count-controlled iteration.

I can identify and explain the purpose of a onedimensional array.

I can identify and describe data types in Python programs, including integer, real, character, string and Boolean.

I can develop a Python program with countcontrolled loops.

I can access data from an array using Python.

I can develop Python programs using string manipulation, including length, uppercase and lowercase.

I can use iterative development on Python prototypes to create solutions to problems.

I can evaluate the processes that are followed to develop programs.

Sample ©Hodder Education

56 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 56 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd

Learning objective

9P.08 Know how to develop and apply test plans that include normal, extreme and invalid data.

9P.09 Identify test data that covers normal, extreme and invalid data.

9P.10 Identify a range of errors, including syntax, logic and runtime errors.

9P.11 Use trace tables to systematically debug text-based programs.

Keywords

9.1 Presenting choices: Combining constructs

Success criteria for students

I can develop and apply test plans that include normal, extreme and invalid data.

I can identify test data that covers normal, extreme and invalid data.

I can identify and describe a range of errors, including syntax, logic and runtime errors.

I can use a trace table to check the flow of a variable through an algorithm and a Python prototype.

Flashcards for the following keywords are available in the Boost online resources: l dr y run l evaluation

Starter

l Focus students’ attention on the success criteria. Prompt students to take this opportunity to request a review of any content already covered before embarking on the ‘Final project’.

l A sk students to reread the ‘Scenario’ at the start of the unit in the Student’s Book. Ensure that students understand the given criteria for the chatbot.

l Students should complete the ‘Final project’ individually, but you can provide guidance on a oneto-one basis to those students who require it.

Activity notes and answers

Final project (Student’s Book page 52)

l The ‘Final project’ for this unit contains five parts (‘Plan’, ‘Develop the algorithm’, ‘Test the algorithm’, ‘Development’, ‘Evaluation of the prototype’).

l Stress that students should consider debugging opportunities in each iteration to develop the program continuously throughout planning and creation stages.

©Hodder Education

l In all tasks, remind students to save their work regularly and to include their name or initials in the files that they create.

l Monitor students’ progress as they work through the tasks. For students who are struggling or for those who need more stretch, refer to the ‘Differentiation’ section below.

l Provide students with the following list of the files they must submit when they have completed the ‘Final project’ tasks.

– ‘Plan’: Word-processed or handwritten, including a table listing the variables, data types and arrays.

– ‘Develop the algorithm’: Word-processed or handwritten pseudocode with annotations.

– ‘Test the algorithm’: Completed trace table; created test plan.

– ‘Development’: FinalProjectV1.py

– ‘Evaluation of the prototype’: Word-processed or handwritten paragraph.

57
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 57 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample
58
2
CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE Answers Part 1: Plan 1 Possible questions include: – What subjects do you enjoy?
What subjects are you good at?
Variables are individual but need to be suitably named, e.g. ‘option1’.
3
1
1
2
3
4
5 6 OUTPUT
7
8 OUTPUT
9 OUTPUT
10 11 OUTPUT
12 13 FOR
14 OUTPUT
15 ENDFOR 16 17 FOR
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 58 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
Variable Data type Name String i Integer choice1 Integer choice2 Integer Item Integer
Array name = subjects Array name = enjoy Array name = chosen Part 2: Develop the algorithm
Here is a possible solution is.
START
ARRAY subjects = "History" "Geography" "Music" "Drama" "Art" "Design and Technology" "Computer Science" "ICT"
ARRAY enjoy
ARRAY chosen
"Welcome to the subject choice chatbot"
name = INPUT capitalised "Please enter your name"
name "I am going to help you choose 3 subjects to continue studying"
"--------------------"
"First, I would like you to select 5 subjects from the following list:"
i = 0 to length of ARRAY subjects
i+1, ARRAY subjects[i]
i = 0 to 4
©Hodder Education

9.1 Presenting choices: Combining constructs 18 choice1 = INPUT "Enter the number of a subject you enjoy: "

IF choice1 >= 1 and choice1 <= length of ARRAY subjects THEN

append subjects[choice1 – 1] to ARRAY enjoy

OUTPUT "That was not a valid choice"

OUTPUT "Now, I would like you to select the 3 subjects that you are best at"

OUTPUT "Here are the subjects that you enjoy:"

FOR i = 0 to length of ARRAY enjoy

OUTPUT i+1, ARRAY enjoy[i]

ENDFOR

FOR i = 0 to 2

choice2 = INPUT "Enter the number of a subject you are good at: "

IF choice2 >= 1 and choice2 <= length of ARRAY enjoy THEN

append enjoy[choice2 – 1] to ARRAY chosen

OUTPUT "That was not a valid choice"

©Hodder Education

59
21
22
23
24
25 26
27
39
40
41
42
43 44
45 46
47
48
49
50
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 59 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
19
20
ELSE
ENDIF
ENDFOR
OUTPUT "--------------------"
28
29
30 31
32
33
34 35
36
37
38
ELSE
ENDIF
ENDFOR
OUTPUT "--------------------"
OUTPUT name "You should consider studying the following subjects next year:"
FOR item in chosen
OUTPUT item
ENDFOR
STOP

2 The array ‘subjects’ stores the list of subjects to select from. The arrays ‘enjoy’ and ‘chosen’ store the subjects the user selects. The count-controlled loops output each item stored in the array, and allow the user to choose their options. 3 The data types used are integers for the subject choices and count variables and a string for the user’s name. Float/real numbers are not used as no decimal numbers are used in this program. A Boolean data type is used as the output to the selection conditional statements.

String manipulation has been used in this program to give an initial uppercase letter to the user’s name when input.

Eesa I am going to help you choose 3 subjects to continue studying

60 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
1 Trace table with inputs
choice1:
Line ArrayArrayArray VariableVariableVariable Condition Variable Condition Variable Output subjects enjoy chosen name i choice1choice1 >= 1 and choice1 <= length of subjects choice2choice2 >= 1 and choice2 <= length of enjoy item 2 History,
6
7 Eesa
8
9 11
14 0 1
14 1 2
14 2 3
14 3 4
14 4 5 Art 14 5 6
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 60 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample ©Hodder Education
4
Part 3: Test the algorithm
as
1, 3, 5, 8, 7 and choice2: 2, 5, 1:
Geography, Music, Drama, Art, Design and technology, Computer science, ICT
Welcome to this subject choice chatbot
Please enter your name
First, I would like you to select 5 subjects from the following list:
History
Geography
Music
Drama
Design and technology

7 Computer

7 8 ICT 18 01 Enter the number of a subject you enjoy

TRUE 20 History 18 13 Enter the number of a subject you enjoy 19 TRUE 20 History, Music 18 25 Enter the number of a subject you enjoy 19 TRUE 20 History, Music, Art 18 38 Enter the number of a subject you enjoy 19 TRUE 20 History, Music, Art, ICT 18 47 Enter the number of a subject you enjoy 19 TRUE 20 History, Music, Art, ICT, Computer science 26 28 Now, I would like you to select the 3 subjects that you are best at

©Hodder Education

61 9.1
Line ArrayArrayArray VariableVariableVariable Condition Variable Condition Variable Output
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 61 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
Presenting choices: Combining constructs
14 6
science 14
19

29 Here are the subjects that you enjoy 32 0 1 History 32 1 2 Music 32 2 3 Art 32 3 4 ICT 32 4 5 Computer science 36 0 2 Enter the number of a subject you are good at 37 TRUE 38 Music 36 1 5 Enter the number of a subject you are good at 37 TRUE 38 Music, Computer science 36 2 1 Enter the number of a subject you are good at 37 TRUE 38 Music, Computer science, History 44 46 You should consider studying the following subjects next year: 48 0 Music 48 1 Computer science 48 2 History

©Hodder Education

62 CAMBRIDGE LOWER SECONDARY COMPUTING 9 TEACHER'S GUIDE
ArrayArrayArray VariableVariableVariable Condition Variable Condition Variable Output
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 62 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Line
Sample

9.1 Presenting choices: Combining constructs

2–3 Here is an example of possible normal, extreme and invalid test data; this could be expanded for more possible inputs and combinations of inputs from array options.

Test Test data

Normal eEsA

Expected outcome Pass/fail

Eesa I am going to help you choose 3 subjects to continue studying

Normal 5 Art (in list of subjects enjoyed)

Extreme 1 History (in list of subjects chosen)

Invalid 0 That was not a valid choice

Part 4: Development

1–2 For a possible solution, refer to finalProjectV1(Teacher).py

3 Students should use their program code to work through a copy of the trace table they created in Part 3.

4 Students can use the test plan they created in Part 3 to test that the program code works as expected.

5–6 Students need to save a new version of the program prototype, e.g. finalProjectV2.py, once they have identified and corrected any errors.

Part 5: Evaluation of the prototype

1–3 Analyses should include that:

– an iterative process allows the program to be created, tested and reviewed continuously to ensure that the program is fully functional and meets all requirements, before the final program is released for someone to use

– a trace table allows the programmer to check the flow of an array, variable and conditional statement through a program to look for errors such as logical ones linked to comparison operators; this is a tool to help find and fix errors before the program is released to a user – a test plan looking at normal, extreme and invalid inputs allows a programmer to check that the program gives the outputs expected and can deal with unexpected inputs, e.g. using else to give a suitable message for an invalid input.

Development iterations will differ based on each student’s own testing and reviews, e.g. they may find that they have not considered the output if the user enters an invalid input; this will lead to additional code being added, and the student should save the program code as a new iteration, with clear version control, i.e. V2, V3, etc.

4 A logical error occurs when the program runs but does not give the output expected. This could be linked with a comparison operator that has been used incorrectly.

A syntax error is an error in the structure of the program code, and it generates an error as soon as the program is run. The error message can help to find and fix the problem.

A runtime error occurs while the program is being run if, for example, a variable name has been spelled incorrectly. It produces a traceback message that helps to find and fix the error.

63
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 63 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd
Sample ©Hodder Education

Review

Evaluation

(Student’s Book page 53)

1 Allow appropriate time at the end of the ‘Final project’ for students to carry out the ‘Evaluation’ exercises. Remind students that part of evaluating a product is gathering feedback from users. Ask students to evaluate their programs in pairs using the questions provided in the Student’s Book and to make a list of recommendations.

2–3 Once students have read the peer feedback, allow them time to make additional changes before submitting their ‘Final project’.

What can you do? (Student’s Book page 54)

l Students should review in pairs the contents of the ‘What can you do?’ box at the end of the unit. If students are not confident in any of the learning outcomes, spend time on areas of misunderstanding before progressing to the next unit of study.

l A sk students to complete the 9.1 Knowledge test . Use this test to assess their understanding of data types, types of tests, Python programming, arrays, count-controlled iteration and string manipulation. Remind students to read the questions carefully to ensure that their answers are correct, and to read the program-code examples fully to select the correct answer.

Homework

Education

l Students could complete tasks 2–3 of the ‘Evaluation’ box if they were unable to finish them during lesson time.

l Students could also finish the 9.1 Knowledge test if they didn’t complete it in the Review stage of the lesson.

Differentiation

Final project

Stretch: To make Part 4 more challenging, students should consider how the chatbot would show that it has finished, to make it act more like a human interaction, e.g. would the chatbot check that the user is happy and ready to end the session or offer further steps if a decision has not been reached? Remind students to test any updates and save these as a new iteration of the program. For a solution, refer to finalProjectStretch(Teacher).py

Support: Some students may need support in Part 5 to understand how to evaluate a process that they have been told needs to be completed. Ask students ‘what’, ‘when’, ‘how’ and ‘why’ questions, linked to each process, e.g.:

l What is the process? (A trace table is created to track the content of a variable or array through conditional statements and outputs.)

l When do you complete it? (It can be completed on an algorithm and on the program code.)

l How is it completed? (A structured table is created to allow the line number and the code to be tracked throughout.)

l Why is it completed? (To locate errors.)

64
LOWER SECONDARY COMPUTING 9
CAMBRIDGE
TEACHER'S GUIDE
369818_9.1_Camb_LS_CS9_TG_010-064.indd Page 64 29/12/22 9:11 AM f-0229-MAC /103/HO02751/work/indd Sample
©Hodder

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.