Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.computerscienceuk.com Learning the skills for programming Advanced Visual Programming.

Similar presentations


Presentation on theme: "Www.computerscienceuk.com Learning the skills for programming Advanced Visual Programming."— Presentation transcript:

1 www.computerscienceuk.com Learning the skills for programming Advanced Visual Programming

2 www.computerscienceuk.com Quick Review of Last Lesson Event Driven Programming Blocks of code can be run when certain events occur Random Function In Scratch there is a function to pick a random number

3 www.computerscienceuk.com Learning Objectives – Remember what is meant by “event-driven” computer programming – Remember how to generate a random number in scratch – Understand what a variable is – Understand how computer make decisions (IF Statements Lesson Outcomes – Produce a Magic 8-Ball program Literacy – Key Words VariableA place where programs store data – think of them as storage boxes. IF StatementThe code needed to get programs making decisions.

4 www.computerscienceuk.com Variables If you were playing a game and rolled a dice, you would need to memorize the number and then use the number to move your counter around the board. When programs work with data they need to memorize things too (even if its just for a second). Programs don’t have brains to store their data, instead they have variables. I rolled a 6 – I must remember that so I can move my counter ?

5 www.computerscienceuk.com Hands up if you can explain what a variable is?

6 www.computerscienceuk.com What is a variable? In programming, a variable can be thought of as a storage box. The box may be given a name, and it may hold various different things. In scratch, is the name of a ready made variable, and it will store what ever you type into scratch. Variable called ‘ANSWER’ Contents is anything we type in Storage

7 www.computerscienceuk.com Creating New Variables But we can also create our own storage boxes (variables) To create a variable we: -click on the variables button -Make a variable -Give it a name We can then set the box to a particular value – in other words “put some data in the box”

8 www.computerscienceuk.com Variables - Summary Variables are the name of the box Contents is any data the program needs to keep hold of Variables are storage boxes which programs use to hold/store data Programmers can create as many variables as they like.

9 www.computerscienceuk.com Hands up if you can explain what a variable is?

10 www.computerscienceuk.com Hands up if you can explain how IF statements work?

11 www.computerscienceuk.com IF statements are how programs make decision. IF this occurs, I will do this ELSE, I will do that IF – ELSE statements allow programs to make decisions based on certain conditions occurring.

12 www.computerscienceuk.com The IF Statement What is this script going to do? When we click the sprite a random number is generated and stored in the variable called ‘number’. If number = 1, the cat will say “ your random number is 1”. If number = 2 the cat will say “ your random number is 2”.

13 www.computerscienceuk.com Hands up if you can explain how IF statements work?

14 www.computerscienceuk.com Magic Eight Ball You shake them and they give you a random message – they are fortune tellers! …and you are now going to program one!

15 www.computerscienceuk.com Planning before we program Before programmers start programming, they always start by imagining the program as a real life object, as a human perhaps. If you were a magic 8 ball what would you do? 1.Wait to be shaken 2.Pick a random statement 3.Say the random statement Write down your thoughts on a whiteboard

16 www.computerscienceuk.com If you were the 8-ball program, what would you do? Wait for user to shake 8-ball (Event / Input) Random number would then be generated You would memorize the number (store it) You would decide what the number means (process it) You would then output a message based on that random number INPUT STORE NUMBER IN VARIABLE What does a 1 mean? OUTPUT Message

17 www.computerscienceuk.com Planning INPUT Wait for user to shake 8- ball (Event / Input) HOW?

18 www.computerscienceuk.com Planning = Algorithm Random number would then be generated You would memorize the number (store it) HOW? STORE NUMBER IN VARIABLE

19 www.computerscienceuk.com Planning = Algorithm You would decide what that means (process it) HOW? What does a 1 mean?

20 www.computerscienceuk.com Planning = Algorithm You would then output a message based on that random number HOW? OUTPUT Message

21 www.computerscienceuk.com Task Create your own Magic 8-Ball program – It must have an image which the user can click – When its clicked it must select a random statement and display it on the screen Extend by developing the look of the program – improve the image, background or even animate the ball.


Download ppt "Www.computerscienceuk.com Learning the skills for programming Advanced Visual Programming."

Similar presentations


Ads by Google