SHOP

PLAY

CREATE

7

Learn how to use conditions (part 2)

Min. Age: 5+ Mother and son; age icon Duration: 20 min. Mother and son; age icon

Video Example:

Material required: Download material .pdf

program BEGIN block
BEGIN block
program END block
END block
Variable block
Variable block
Assignment block
Assignment block
Random function call
Random function call ('die roll')
Two dice: one dotted and another with numbers
Die of choice
Number tiles for board game
Numbers
Relational operators
Relational operators
Condition block
Condition blocks
Code block
Code blocks
Direction blocks for block-programming
Direction blocks
Function calls for drawing geometric shapes
Function calls for drawing geometric shapes
Whiteboard and marker
Whiteboard and marker
Digital Timer
Timer

Play

1

What is our goal?

You must be very quick!

The goal shared by the players is for the player interpreting the code to guess correctly what the drawing player is drawing before time runs out.

2

How do we play?

The game is played with 2 players: One player who moves the pieces through the blocks by reading and interpreting the code, and another player who draws.

3

How do we start?

1

This game is a variation of activity 5, so place the same blocks in the same way:

Block based program conforming a game for conditional function calling
2

The drawing player imagines what they want to draw on the board without telling the other player. For example, "a dog".

Draw and guess coding game, player imagines a dog.
3

Set the timer to 5 minutes. In subsequent games, you can lower the time as a challenge.

You can play the first game without a timer until you integrate the dynamics of the game, especially if the players are children aged 4-7 years.

Digital Timer

Are you ready?!

4

What do I do during my turn?

Once the time starts, the player interpreting the code does so just like in activity 5, calling the functions to draw geometric figures according to the evaluation of the conditions. The other player is obliged to draw the figures that come up, trying to draw the picture he/she imagined.

5

When does the game end?

The game ends when the player guesses correctly what the other player is drawing or when the timer reaches zero. If the player guesses correctly what the other player is drawing, both players win. If the timer reaches zero before the player guesses correctly what the other player is drawing, both players lose.

Drawing done by kids of a dog for Sketch and guess coding game

"Oh no! We lost! It's neither a mouse nor an elephant! It's a dog!


Puzzles:

Write 1

5+ years

Using the necessary blocks, rewrite the same program as above by changing the conditions and using other functions (for example, the "draw pentagon" function, or the 'undo' or 'flipBoard' function, or inventing others).

Alternative function calls

Write 2

6+ years

Using the necessary blocks, write a program that draws a geometric figure according to the result of a die roll (use the random function):

  • If the die roll result is 1, the program draws a circle,
  • If the result is 2, it draws a triangle,
  • If the result is greater than or equal to 3, the program draws 3 geometric figures: a rectangle, a line, and a semicircle.
Show answer

Answer:

Conditional function call program

ReadWrite3

7+ years
1

Read the following "code". What is the value of the variable 'a' at the end of the program?

Conditional subtraction program
Show answer

Answer:

2

2

Without changing the conditions, modify the previous code so that the first condition is always met.

Show one possible solution

Possible solution:

Correction of a bug in a conditional subtraction program

Read 4

8+ years

The following written code contains a condition. The code with blocks below is its equivalent.

One condition simple program if else

What geometric figure does this program draw?

Show answer

Answer:

A circle

Read 5

10+ years

Read the following written code. What geometric figure is drawn in case the random function call returns '3'?

Show answer

Answer:

A triangle

Write 6

10+ years

Write the code of the Sketch'n Guess Game (See video).

Show one possible solution

Possible solution:

Test following code:


ReadWrite7

7+ years
1

Read the following "code" and answer the question: What figure is drawn when executing the code?
The arithmetic operators '<=' ("less than or equal to") and '>=' ("greater than or equal to") are used.

Nested if program
Show answer

Answer:

A triangle
2

Modify the previous code in such a way that another condition is met.

7+ years
Show one possible solution

Possible solution: Change the sum in the assignment

Correction of a bug in a nested if program
3

Complete the following written code to be identical to the previous code with blocks:

12+ years
Show answer

Answer:


Write 8

12+ years
If else program

Read the previous code with blocks and write it down below:

Show answer

Answer:


Debug 9

9+ years

A programmer has an error in his program and can't see it!: The "draw semi-circle" function is never executed. Try to correct the code by modifying only one condition.

Thinking developer because of a bug
Sketch and guess block program
Show answer

Answer:

Correction of a bug in a Sketch and Guess Game program

Debug10

12+ years

"Oh no! The following code doesn't do what we want it to do. For some reason, the variable 'i' is greater than 0 at the end of the code execution. We were expecting a value of 0 for 'i'. Help me correct the code."

Thinking developer because of a bug
Show one possible solution

Possible solution:


Write11

10+ years

In the following code; call the 'random' function and assign the value to the variable 'a'.

Write the code to do the following:

  • If the value of 'a' is equal to 1: print "Circle" using console.log("Circle"); ,
  • If the value of 'a' is equal to 2: print "Rectangle",
  • If the value of 'a' is equal to 3: print "Triangle",
  • If the value of 'a' is equal to 4: print "Line" ,
  • Otherwise: print "Semi-circle" and "Curve".
Random call assignment
Show answer

Answer: