LESSON 1 (Variables)

Learning Objectives

LO: Understand what variables are and why and when to use them in a program

LO: Understand the importance giving variables logical names

STARTER

What is a Variable?

MAIN

Click here to open the code window!

Tasks

1.Create a program like the one shown below. What does it do?

mb1

2.Create a new variable, name it “adjustment“, set it to 3 and put it in the on start block (Click here for help)

3.Instead of setting “count+/- 1, set count to +/- adjustment (Click here for help)

4.Use the A+B buttons pressed event handler to reset the counter to 0 and display it

5.Create your own variable on start. Change the variable in the on shake event.

Example: My variable is called maraca. When I shake it the variable goes down by 5. This shows how sad my mother gets when I play the maraca in her ear.

Knowledge Check

Click on this link to check your learning


LESSON 2 (Selection)

Learning Objectives

LO: Understand selection statements

LO: Understand the ‘if…then…else’ logic block

Slide1

MAIN

Click here to open the code window!

Tasks

1.Create a program like the one shown below. What does it do?

PIC1

(Click here for help)

2. Can you edit your program to show string “Sunny / Warm” before the “Play Outside!” string

(Click here for help)

3. Can you edit your program to show string “Stay Inside…” after the “Raining” string

4. Can you edit your program to display a suitable image for the “Raining” scenario and the “Sunny / Warm” scenario. Use the block below to help you…

1

5. Can you edit your program so it generates a random number between 0 and 3. Your program should then have 4 different weather scenarios; Raining, Sunny/Warm, Snowing/Cold & Windy. It should output an appropriate message for each and the show an icon.

SOLUTION

Knowledge Check

Click on this link to check your learning


LESSON 3 (Iteration)

Learning Objectives

LO: Understand that iteration is repeating a process such as a loop

LO: Understand the process of repeating code a fixed number of times

Starter

MAIN

1.Create a program like the one shown below. What does it do?

Picture1

(Click here for help)

2. How could we count up to number seven instead? Edit your code so it does this

3. What about counting up to number nine? Edit your code so it does this

4. Can you count from 0 to 3 and then show a heart for 3 seconds? For this I would like to create a second loop within the forever block!

(Click here for help)

5. Now, let’s count from 0 to 2, show a heart for 4 seconds but this time it blinks, and finally show the word “Go” 3 times.(Hint: To blink you need to clear the screen. Also, all blocks will be used for this challenge)

(Click here for help)

Knowledge Check

Click on this link to check your learning


LESSON 4 (Functions)

Learning Objectives

LO: Understand programming functions

LO: Understand how functions can be used to organise code

Presentation1

1.Create a program like the one shown below. What does it do?

Picture1

(Click here for help)

2. Can you program Herbert to exercise when both buttons A and B are pushed?

Hint: Use the exercise function, roller skate icon, and A+B event handler.

3. Can you program Herbert to do a new action on shake?

4. One benefit of functions is writing code and then being able to reuse it easily. Look at the ASLEEP and DRINKING functions. What code is the same? Can you make a new function for this repeating code? Call your function BLINKING.

Advertisements