compy9_2_bbc_basic_ - lady · web viewmost : describe some different types of computer model;...

22
LLS ICT Dept 2014-15 Year 8 - Computing CompY9 BBC Basic Modelling 9_2 Overview for Students Students learn about modelling with the BBC Basic programming language. You will write programs which will become subroutines for your lemonade stand model. Summary The unit covers the topic of Modelling, using a programming language designed to make programming easy and approachable for beginners. After covering the rudiments of BBC Basic and its programming environment, pupils start to write small programs which will eventually become subroutines in their Lemonade Stand model. The pupils will discuss some of the different areas in which models are used, from climate change to business enterprises, and the limitations of their own model. The unit assumes that pupils have already completed a basic programming unit in a textual language such as BBC Basic or Python. It moves quickly through the concepts of selection and iteration, giving practice in each of these, before covering subroutines and modular programming. The pupils’ final models are put into a learning portfolio with evidence of correct running, for assessment purposes. They also answer questions about computer modelling and perform a self-evaluation. New Attainment Targets (partially covered in this Unit) Design, use, and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems. Use two or more programming languages, one of which is textual, to solve a variety of computational problems; make appropriate use of data structures; design and develop modular programs that use procedures and functions 1

Upload: lenga

Post on 18-Mar-2018

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

9_2 Overview for Students

Students learn about modelling with the BBC Basic programming language. You will write programs which will become subroutines for your lemonade stand model.

SummaryThe unit covers the topic of Modelling, using a programming language designed to make programming easy and approachable for beginners. After covering the rudiments of BBC Basic and its programming environment, pupils start to write small programs which will eventually become subroutines in their Lemonade Stand model. The pupils will discuss some of the different areas in which models are used, from climate change to business enterprises, and the limitations of their own model.

The unit assumes that pupils have already completed a basic programming unit in a textual language such as BBC Basic or Python. It moves quickly through the concepts of selection and iteration, giving practice in each of these, before covering subroutines and modular programming.

The pupils’ final models are put into a learning portfolio with evidence of correct running, for assessment purposes. They also answer questions about computer modelling and perform a self-evaluation.

New Attainment Targets (partially covered in this Unit)● Design, use, and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems.● Use two or more programming languages, one of which is textual, to solve a variety of computational problems; make appropriate use of data

structures; design and develop modular programs that use procedures and functions

Learning Outcomes for the unitAt the end of this Unit all pupils should be able to:● All : Write and run a program in BBC Basic● All : Find and correct syntax errors in a program● All : Use comparison operators =, >, <, >=, <=, <>● All : Use Logical operators And and Or● All : Use a While loop and a For loop in a program

1

Page 2: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling● All : Divide up a list of tasks into discrete subtasks which could be written as subroutines● All : Name some applications of modelling● All : Name some of the relevant factors and measurements involved in the Lemonade Stand model● All : Complete the Lemonade Stand model with some help● All : Run and record results from the model

Most pupils will be able to:● Most : Write a program involving random number generation to find the answer to a question, e.g. the chances of throwing a double six when

rolling two dice● Most : Explain what is meant by a modular program● Most : Write a simple program involving at least two subroutines● Most : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

world, models of the environment, business models, etc.● Most : Explain the purpose and advantages of using a computer model● Most : Explain the limitations of a model

Some pupils will be able to:● Some : Write a modular program involving several subroutines to model a real-life scenario -Some : Amend a model to make it perform better● Some : Devise alternative algorithms for modelling a situation to give a realistic outcome ● Some : Add code to their programs to enhance the lemonade stand model; e.g. to allow the user to run the model as many times as they like in a

single run, to allow the user to enter ranges of temperature or footfall at run time, etc.

Previous Learning

Pupils should have completed an introductory unit covering basic programming techniques in a textual language such as Python or BBC Basic before starting this unit. Familiarity with using selection (If…Then…Else) and iteration (For and While loops) will be very helpful.

Suggested Resources

BBC Basic software (free to download)

PowerPoint lessons 1 to 6

Worksheets 1 to 6

2

Page 3: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

Vocabulary

Vocabulary associated with this Unit, such as:

Syntax, programming environment, Intellisense, variable, string, concatenation, function, arithmetic operator, assignment statement, comparison operator, logical operator, selection, loop, increment, subroutine, random number generation, model, modelling, footfall

Assessment

Pupils will need an extra period to complete an assessment portfolio at the end of the Unit. They will answer questions on Modelling, paste in evidence of their model and complete a brief self-assessment.

About BBC Basic

BBC Basic was invented in in 2008 by Vijaye Raji, a developer at Microsoft, and version 1 was launched in 2010. Its predecessor, BASIC, was invented in the 1960s and went through numerous major revisions, becoming more powerful and complex with each revision. (There are over 200 documented dialects of BASIC!) BBC Basic was designed to be a really simple programming language which is easy for beginners to use to write programs and grasp basic concepts and programming structures. It has only 14 keywords and runs in a simple programming environment that gives context-sensitive help and makes writing and testing code as simple as possible. However, unlike Scratch and Kodu, for example, which are great tools for enabling pupils to write “codeless” programs, BBC Basic introduces code from the very beginning.

BBC Basic is a .NET language, which Microsoft describes as “a toned down version of Visual Basic.NET”, and runs on the Microsoft .NET framework.

HML (100mins)LOs (BTEL)

Activities Home Learning and Portfolio Evidence

Teacher Notes

Lesson 1 : Introduction● All : Write and run a

program in BBC Basic● All : Find and correct

syntax errors in a program

Preparation● Make sure that BBC Basic is installed on the pupils’ computers.

Starter: Ask pupils how many programming languages they can name. Why are there so many? How many have they used? Are all programs written in the same way – e.g. by writing text, dragging icons on to a window, selecting from a number of different options.

Talk about syntax rules and explain that each language has its own set of syntax rules. If they have programmed in say, Python, they will find the BBC Basic syntax similar but different!

Print off the completed basic workbook 01 v2and put it in folder.

basic workbook 01 v2

Modelling in BBC

3

Page 4: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic ModellingLearning Objectives:● Explore the BBC

Basic environment● Use Intellisense to

type programs faster● Learn how to write

and run a simple BBC Basic program involving input, output and variables

-----------------------------------

CalculationsLearning Objectives:● Understand what is

meant by a variable● Input and output

numeric variables● Perform calculations

in BBC Basic● Working with strings● Use mathematical

functions (methods) in a program

Main Activity:

Ask pupils to load BBC Basic. Point out the different areas of the screen and ask them to type in and run the “Hello world” program. Experiment with what happens when an error is made. Are the error messages easy to interpret?

Explain what is meant by BBC Basic’s “Intellisense” feature. It saves a lot of typing and results in fewer typing errors so is very useful. The context-sensitive Help bar is also very helpful for getting information on different statements.

Encourage the pupils to use plenty of comments to document their code.

Give out basic workbook 01 v2. Ask pupils to complete Project 1.

Make sure all pupils understand what a variable is, and go over the rules for naming variables. Try and establish good naming habits early on!

Show pupils the INPUT Command statement and then ask them to complete Project 2 on the worksheet.

-------------------------------------------------------------------------------------------------------------------------

Main Activity:

Discuss the meaning of a variable - solving for x. Use normal mathematical expressions , like 2 +2 = x. Move on to a discussion of Arithmetic operators and use of variables.

Demonstrate the use of calculations, variables and conditional statements.

Have students complete Project 3 on the worksheet.

Discuss the meaning of strings. Computers can read and compare text. That is how computers find keywords when you type them into google.

Demonstrate the use of strings.

Have students complete Project 4 on the worksheet.

--------------------------

Basic TextWindow properties and operations

-----------------------

4

Page 5: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

5

Page 6: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

HML (100mins)LOs (BTEL)

Activities Home Learning and Portfolio Evidence

Teacher Notes

Lesson 2 : More Calculations and Selection

● All : Use comparison operators =, >, <, >=, <=, <>

Learning Objectives:● Use Comparison operators =,

>, <, >=, <=, <>● Use selection statements to

make decisions● Use Repetition statements● Use Colours

----------------------------------Lesson 4 : Loops● All : Use a While loop and a For loop

in a program

Learning Objectives:● Use a While loop to repeat a section

of code until a condition becomes false

Starter:

Go through the comparison operators, and examples of If..Then and If..Then..Else statements. Show how they could write a selection statement when there are lots of different values to be tested, using the If - Else statement.

Main Activity: Discuss the need for the user of a program to be able to interact with a program. What would games be like if the user couldn’t use a controller or a joystick, etc.? How much fun would a game be, if no matter what you did the game wouldn’t change what it was going to do? Games and other programs need to adapt to what the user needs them to do.

Demo a selection statement. See the Lemonade Stand Program.

In this lesson we will learn about selection statements and repetition. Have students load and began basic workbook 02 v2.docx and complete Project 5

Print off the completed basic workbook 02and put it in folder.

HL - have them write a program that creates a name badge for visitors to Lady Lumleys; Name, Visitor type, as an extension - see if some of them can create a badge number that automatically increments by one.

Or have them create a program for a Lemonade Stand - calculating price and quantity.

basic workbook 02 v2.docxbasic workbook 03 v2.docx

Badges and Lemonade Stand completed programs on Fronter Y9 resources page.

6

Page 7: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling● Use a For loop to repeat a section of

code a given number of times● Model a dice-rolling experiment

Demo a repetition statement. See the Badges program. Have students complete Project 6 in basic workbook 02 v2. docx.

Demo the use of Colour.

Have students load and began basic workbook 03 v2.docx, Project 6 Colour.--------------------------------------------------------------------------------------------------------------

Ask the pupils to complete Activity 2, for homework if time is running short.

-------------------------

-----------------------------PowerPoint Guide: Modelling in BBC Basic L4 Loops and arrays

PP L4 While Loop Demonstration.sb

Modelling in BBC Basic Worksheet 4 Loops

PP L4 While loop demonstration

W4 DieRoll.sb

W4 DieRoll Extension task1.sb

W4 DisplayRunningTotal.sb

7

Page 8: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

Homework: Extension activities on BBC Basic Worksheet 4 Loops. These are quite challenging exercises and you will have to decide whether they are appropriate for your pupils.

W4 Extension tasks 3-4 Monte Carlo Method.sb

8

Page 9: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

9

Page 10: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

HML (100mins)LOs (BTEL)

Activities Home Learning and Portfolio Evidence

Teacher Notes

Lesson 5 : Using subroutines to build a model

● All : Divide up a list of tasks into discrete subtasks which could be written as subroutines

● All : Name some of the relevant factors and measurements involved in the Lemonade Stand model

● All : Complete the Lemonade Stand model with some help

● All : Run and record results from the model

● Most : Write a simple program involving at least two subroutines

● Most : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy world, models of the environment,

● Most : Explain the limitations of a model

Learning Objectives:● To understand the concept of a

subroutine● To create a model of a

Lemonade Stand● To work out what subtasks are

Starter: Introduce the idea of modular programming: a program consisting of a “main” section which calls small, self-contained subroutines or modules to perform the various smaller tasks involved.Main Activity:Give out Worksheet 5 and ask pupils to complete Activity 1. You may need to give the class some help to start them off on the right track. They may come up with something like:Start of program:WashClothes()Charge mobilePack()CheckTravelArrangements()End of program(Then the “subroutines”)Sub WashClothes Wash Jeans Wash Blue T-shirt Wash SocksEndSubSub Pack Pack Phone Charger Pack Clothes

PowerPoint Guide: Modelling in BBC Basic L5 Using subroutines to build a model

Modelling in BBC Basic Worksheet 5 Developing the model

10

Page 11: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modellingrequired in the model

● To prepare subroutines for each subtask

● To write a program incorporating the subtasks as subroutines

Pack WashkitEndSubSub CheckTravelArrangements Find passport Find ticket Check in onlineEndSubThere is no one “correct” answer – some pupils could tell the class what they have come up with for the others to discuss.In the above solution “charge phone” has not been put into a subroutine as it doesn’t seem to fit anywhere. It needs to go somewhere before “Pack Phone Charger”Computer modellingDiscuss examples. If the global warming model had predicted 20 years ago that the average temperature in England would now be 5 degrees higher, would people trust it? What action will the model builders take?The Lemonade Stand ModelWhat is the point of building a model of a Lemonade stand?When you build a model to predict sales, you have to make assumptions as to the weather, footfall (number of people passing the stand), price people will pay, popularity of lemonade compared to the Coke and ice-cream stand 20m away, and so on.

BBC Basic programs:

W2CostOfLemonade

W2 GetRandomTemperature

Modelling in BBC Basic Worksheet 5 Developing the model

W5 Lemonade Stand Model Steps 1-2.sb

W5 Lemonade Stand Model Steps 1-4.sb

11

Page 12: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modelling

-------------------------------Lesson 6 : Evaluating the model

● Some : Add code to their programs to enhance the lemonade stand model; e.g. to allow the user to run the model as many times as they like in a single run, to allow the user to enter ranges of temperature or footfall at runtime, etc.

● All : Name some applications of modelling

● Most : Explain what is meant by a modular program

● Some : Write a modular program

Then you have to create algorithms to imitate real-life, which always has random as well as predictable events. We know when weekends are, but we don’t know if it will be pouring with rain all summer!Using subroutines in the modelPupils will now start building the model, using some routines they have already written and some new subroutines that either they can write themselves or that can be provided.Ask pupils to look at Activity 2 in Worksheet 5.Discuss the tasks/subroutines required for the Lemonade Stand model. Remind pupils that they have already written programs CalculateCost and GetRandomTemperature. If any pupils have not got these they can copy them from W2 CalculateCost and W2 GetRandomTemperature, and rename them.Starting to build the modelStep 1: Show the PP slide with the above title to help pupils get started on Step 1. The next slide shows the code that they should have so far – they can add extra lines and comments as required.Step 2: Pupils will add a statement to ask the user to set the cup price. Then they will add a For.. EndFor loop to run the model five times for 5 days, and add all the other subroutine calls into this loop. The code at this stage

W5 Lemonade Stand Model.sb

12

Page 13: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modellinginvolving several subroutines to model a real-life scenario

● Some : Amend a model to make it perform better

Learning Objectives:● State the advantages of using

subroutines to build up a long and complex program

● Suggest how the reliability of the model could be evaluated

● Suggest ways of improving the model

should look something like Lemonade Stand Model Steps 1-2.sb.Step 3: Pupils copy code into the subroutines from their programs GetRandomTemperature.sb (Worksheet 2) and EstimateFootfall.sb (Worksheet 3), make any changes necessary and test the program again. (They may generate and display two random temperatures instead of one – they need to find and debug this error.)Step 4: Pupils add statements to display the day, e.g. Day1, Day 2, etc. each time round the For loop.TextWindow.WriteLine("Day " + Day)They need to add two statements at the end of the For loop to allow the user to look at the output each day before it scrolls off the screen. Something like:

TextWindow.WriteLine("Press Enter to continue") Pause = TextWindow.Read()

Step 5: Pupils have to write subroutine GetCupPrice. The code for this is embedded in in the program LemonadeSales which they wrote in Worksheet 3. It just does the following:

Sub SetCupPrice 'Ask the user to decide the price of a

-------------------------

-----------------------------------

PowerPoint Guide: Modelling in BBC Basic L6 Evaluating the model

Modelling in BBC Basic Worksheet 6 Evaluating the model

13

Page 14: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modellingcup of lemonade TextWindow.WriteLine ("") TextWindow.Write ("Enter the price in pence you are charging for a cup of lemonade: ") CupPrice = TextWindow.ReadNumber() TextWindow.WriteLine ("")EndSubStep 6: Pupils have to write subroutine DisplayRunningTotal. They already have some of the code they need in the program DisplayRunningTotal which they wrote in Worksheet 4.The program at this stage should look something like Lemonade Stand Model Steps 1-4.sb.

Note: Pupils may not be able to complete the model in this lesson. They should finish it for homework, or be given time to finish it in the next lesson.-------------------------------------------------------------------------------------Starter: Hold a discussion with the class on the advantages of building a long complex program using subroutines.Main Activity:Use the PowerPoint slide to remind pupils of the six subtasks that comprise the model. Each of these is written as a subroutine. (Worksheet 5)

14

Page 15: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic ModellingAllow pupils time to finish their Lemonade Stand Models.Pupils should then run their models and fill in results on Worksheet 6. If pupils try entering a very high price for lemonade, say £10,000, they may well find they still sell a few cups and end up millionaires! This is clearly a weakness of the model.Extension task:Pupils who have completed their models may then have time to look at the formula used for calculating sales, which was

If CupPrice less than or equal BestPrice, CupsSold = Footfall *0.2

(20% of people will buy)Else If CupPrice is less than or equal 1.5 * BestPrice, CupsSold = Footfall * 0.1 (10% of people)Else If CupPrice less than 2 * BestPrice, CupsSold = Footfall * 0.05

(5% of people)Else CupsSold = Footfall * 0.01(1% of people)

EndifThey can figure out how to make it more realistic, and amend their programs. (CupsSold needs to be set to zero if price is above a certain maximum.)Discuss how the reliability of the model could be evaluated. It could not be evaluated until it has been running

15

Page 16: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic Modellingfor some time. At the end of the summer, the results given by the model could be compared with the actual figures. If they are in the same ball-park, great! If not – back to the drawing board.Plenary: How can the model be made better?At the end of the summer, once there are some actual sales figures to refer to, actual daily temperatures and measurable footfall, the model can be tweaked until it reflects reality. Of course, this does not mean it will be accurate next year! Modelling is a very difficult art. No wonder we still have climate change deniers even though all the evidence and all the models suggest the contrary is true.Many factors have not been taken into account – weekends, Bank holidays, proximity of another stand, running out of lemonade.Discuss how sales revenue could be improved – e.g. by changing the lemonade recipe (more sugar??), moving the stand, charging more/less, improving the look of the stand, getting help so that you can serve the crowds more quickly, etc.

16

Page 17: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic ModellingHML (100mins)LOs (BTEL)

Activities Home Learning and Portfolio Evidence

Teacher Notes

Lesson 7: Assessment

● Complete the assessment

Allow the pupils to download and complete the self-assessment.

Pupils should leave ample time to complete the questions in the assessment. A screenshot of the program running should be included in the Assessment Portfolio along with the full code listing which they can copy and paste from BBC Basic.

Pupils may upload their completed assessments to an MLE such as Moodle, Fronter or Frog if desired.

BBC Basic Assessment Portfolio.docx

AcknowledgementsThe authors and publisher would like to thank all contributors for their kind permission to reproduce their photographs or images, screenshots of their websites or other copyright material in the PowerPoint Guides.

Every effort has been made to trace the copyright holders and we apologise in advance for any unintentional omissions. We would be pleased to insert the appropriate acknowledgement in any subsequent edition of this publication.

Last PowerPoint slide of Lesson 2 contains public sector information licensed under the Open Government Licence v1.0.

Picture of lemonade glass used on worksheets: http://www.wpclipart.com/food/beverages/lemonade.png.html

Terms of use: http://www.wpclipart.com/terms.html

Photograph of lemons in slideshow five published under the Creative Commons Licence. Photograph by Nina Matthews http://www.flickr.com/photos/21560098@N06/6722653055

Photograph of money and calculator in slideshow six published under the Creative Commons Licence. Photograph by Images_of_money http://www.flickr.com/photos/59937401@N07/5929554283

17

Page 18: CompY9_2_BBC_Basic_ - Lady · Web viewMost : Describe some different types of computer model; e.g. models used by an interior designer, models to play a game or simulate a fantasy

LLS ICT Dept 2014-15 Year 8 - Computing

CompY9 BBC Basic ModellingThis material contains links to relevant websites featured in the teacher’s guide. Every effort has been made to ensure that at the time of distribution, the links remain unbroken, the material remains up-to-date and that links are not inadvertently linked to sites that could be considered offensive. PG Online cannot be held responsible for the content of any website mentioned in this material. It is sometimes possible to find relocated sites by typing the original URL into a browser. Any errors should be reported directly to [email protected] and changes will be made in any subsequent editions of the material.

18