Coding Concepts Activity Solutions

Sequencing

Exercise 1

The cat will pause twice (as there is 2 wait blocks) and it will move 80 steps in total (this is 10 + 20 + 40 + 10 from the move blocks).

Exercise 2

The Cat will appear to not move at all. This is for two reasons. Firstly, we would have to include wait blocks to see the Cat moving around the canvas. As there is no wait blocks, the Cat runs through all of the move blocks in one movement. Secondly, if you add up all of the steps (100, -100, 200 and -200) you get 0. When the Cat moves 0 steps, it doesn’t move at all.

Exercise 3

Yes, the student has explained the code correctly.

Repetition

Exercise 1

As the repeat block will repeat 4 times, the snare drum noise will play 4 times.

Exercise 2

The student is incorrect for two reasons:

  1. The Cat will move to the left (move -10 means move 10 steps to the left)
  2. The Cat will move 10 times in total, not 5

The Cat will actually move towards the left 10 times.

Exercise 3

The Cat will move to the right 6 times in total. The outer loop repeats 2 times. The inner loop repeats 3 times.

Variables

Exercise 1

The variables will be a, b, c, x and y

Exercise 2

The value of times will be 3. The value of times will change like this:

  1. the value of times will start at 0
  2. the value of times will change by positive 2, so it would now be 2
  3. the value of times will change by negative 1, so it would now be 1
  4. the value of times will change by postive 4, so it would now be 5
  5. the value of times will change by negative 2, so it would now be 3

The drum noise will play 3 times, as the times variable is used in the repeat block.

Exercise 3

The 1 in the change times space bar pressed block should be a -1, instead of 1. With a -1 in the change times space bar pressed block, the change times space bar pressed variable will decrease by 1 everytime you press the space bar.

Exercise 4

As the number in the change guest number by block is 2, every second guest in the guest list will be skipped. If we change the 2 in the change guest number by block to 1, every guest in the guest list will receive an email.

User Input

Exercise 1

The Cat will say: Hello John. The join block joins the two bits of text together into one String value.

Exercise 2

To get the program to work as the student expects they should reverse the order of the blocks. The ask and wait block is before the say block but these should be the other way around.

Exercise 3

The student has confused the x and y axes and so all of the change x and change y blocks need to be swapped around.

The correct blocks are shown in the below image:

Branching

Exercise 1

The message: Access Denied! will appear for 2 seconds. This is because the answer will be 12345, which does not equal 1234 and consequently the instructions contained in the else block will be followed. If the user had answered with: 1234, then the message: Access to Secret Documents: Granted would have appeared.

Exercise 2

To have the message: Let’s start the game! appear only when the player is the right age, the last say block will have to be placed after the say block that is third from the top, inside the second else block.

Exercise 3

Before the repeat until:

The first repeat until:

The second repeat until:

The third repeat until:

The program ends: