Search Header Logo
MicroBits revision lesson

MicroBits revision lesson

Assessment

Presentation

Computers

7th Grade

Practice Problem

Hard

Created by

G Alexander-Doyle

Used 2+ times

FREE Resource

10 Slides • 13 Questions

1

media

Code understanding

It is important to ensure you use the correct computational constructs when programming. Here are some examples of some common ones:

Assignment – Putting a value into a variable

Variables can be numbers or strings
- Number – Any whole number
- String – Any combination of text, numbers and special characters.

2

Assignment

In the Micro:Bit coding environment, assignment blocks are coloured in red. They begin with the words Change and Set to substitute a value for another and initialise variables respectively.

media
media

3

The random function

The random function assigns a random number to a variable within a given range. You can pick the range of numbers which the program can pick from. In this example any number between 1 and 3 will be assigned to the number variable.

media

4

Selection statements

selection (or sonditional) statement – A selection statement runs a piece of code only if a condition is met. It allows the program to make a decision. The block is a blue/green colour in the Micro:Bit coding environment and uses the words if, else if and else. It takes the following format…

media

5

Selection Statements

When comparing one piece of data with another we can use the following operators.


< Less than
> Greater than
Greater than or equal to
Less than or equal to
= Equal to
Not equal to

media

6

Selection statements

We can also use else if to have the program test more than one condition in a single construct like below.

media
media

7

Fixed loop

Fixed loop - A fixed loop runs a piece of code a set number of times. Any code placed within the block will run for the number of times entered by the user. The fixed loop block can be found in the green loops category and begins with the phrase repeat _ times do.

Repeat for 1 to 4

End repeat

media

8

Conditional loops

Conditional loop - A conditional loop runs a piece of code until a condition is met. This is useful when the programmer does not know in advance how many times the loop will be required to run (for example when the user is entering a password, they may get it right on the first try or the second or the third).

while condition = true then do

end while

media

9

Conditional loops

The conditional loop block can be found in the green loops category and begins with the phrase while <false> do. The programmer would need to change the <false> block to the condition they wish to test.

media

In this example the number variable will be shown having been multiplied by two and then changed by one while the number is not equal to 20.

10

Conditional loops

while condition = true then do

end while

media

11

Multiple Select

Question image

Which words would you associate with the assignment coding construct? There are two correct answers below.

1

Repeat

2

If

3

Set

4

While

5

Change

12

Multiple Choice

Question image

Which word would you associate with the fixed loop coding construct?

1

Else

2

If

3

Repeat

4

While

5

Change

13

Multiple Select

Question image

Which words would you associate with the selection statement coding construct? There are two correct answers below.

1

Else

2

If

3

Repeat

4

While

5

Change

14

Multiple Choice

Question image

Which word would you associate with the conditional loop coding construct?

1

Else

2

If

3

Repeat

4

While

5

Change

15

Multiple Choice

Question image

What colour are the blocks in the category for loops?

1

Red

2

Green

3

Pink

4

Blue/green

16

Multiple Choice

Question image

What colour are the blocks in the category for selection statements?

1

Red

2

Green

3

Pink

4

Blue/green

17

Multiple Choice

Question image

What colour are the blocks in the category for assignment?

1

Red

2

Green

3

Pink

4

Blue/green

18

Multiple Choice

Question image

What colour are the blocks in the category input?

1

Red

2

Green

3

Pink

4

Blue/green

19

Open Ended

What does the random function do?

20

Multiple Choice

Which of the following operators indicate something is not equal to another?

1

=

2

>=

3

<=

4

21

Multiple Choice

Which of the following operators indicate something is greater than or equal to another?

1

=

2

>=

3

<=

4

22

Multiple Choice

Which of the following operators indicate something is equal to another?

1

=

2

>=

3

<=

4

23

Multiple Choice

Which of the following operators indicate something is less than or equal to another?

1

=

2

>=

3

<=

4

media

Code understanding

It is important to ensure you use the correct computational constructs when programming. Here are some examples of some common ones:

Assignment – Putting a value into a variable

Variables can be numbers or strings
- Number – Any whole number
- String – Any combination of text, numbers and special characters.

Show answer

Auto Play

Slide 1 / 23

SLIDE