ุงู†ุชู‚ู„ ู„ู„ู…ุญุชูˆู‰
Robo EgyptRobo Egypt
โ˜ฐ Course contents
Robo Block: home
0. Lab tour1
1. Getting started5
2. Motion5
3. Looks and sound5
4. Events4
5. Loops5
6. Conditions and sensing4
7. Variables and randomness4
8. Project: the โ€œCatch Roboโ€ game3
9. Messages: characters talk to each other4
10. Clones: one character, many copies4
11. My Blocks: make a new block3
12. Operators and time4
13. The pro project: a jumping game4

๐Ÿ› ๏ธ Section project: the maths quiz

Section 7: Variables and randomnessLesson 7.3 ยท โฑ 15 min

Robo becomes a teacher: he asks you addition questions with random numbers and counts your points.

๐ŸŽฏ Project goal
Robo asks 5 different addition questions. Every right answer adds a point to score, and at the end he says your score.

Steps

  1. Make 3 variables: score, a and b.
  2. Set score to zero at the start.
  3. Inside repeat (5): set a and b to random numbers from 1 to 10, then ask for their sum.
  4. If answer equals a + b, change score by 1 and say Correct!
  5. After the loop, say the score.
๐Ÿงฉ A possible solution
Blocks: when ๐Ÿšฉ clicked, set (score) to (0), repeat (5), say (join Your score: score)
๐Ÿ’ก Tip
The join block sticks words and numbers together, like 3 + 4 in one question.

๐Ÿ“Œ Another example: one question, two answers

if โ€ฆ else chooses: if the answer is 56 he praises you, else he tells you the right answer.

Blocks: when ๐Ÿšฉ clicked, ask (What is 7 ร— 8?) and wait, if <(answer = 56)> then
Robo asks
Robo asks
We typed 56
We typed 56
โœ๏ธ Practise
Build the whole maths quiz here, and test a friend.
โœ๏ธ Practise here in the lessonor open the lab in a new page โ†—

๐ŸŽฏ Challenge yourself

Easy

Robo asks your name, then says โ€œHello,โ€ and your name.

๐Ÿ‘€ Show the solution
Blocks: when ๐Ÿšฉ clicked, ask (What's your name?) and wait, say (join Hello,  answer) for (2) seconds
We typed Mona
We typed Mona
Medium

Robo asks your age: if it is more than 9 he suggests the hard level, else the easy level.

๐Ÿ‘€ Show the solution
Blocks: when ๐Ÿšฉ clicked, ask (How old are you?) and wait, if <(answer > 9)> then
We typed 11
We typed 11
Hard

A times-table quiz: 3 random questions (a ร— b), a wrong answer shows the right one, and the score at the end.

๐Ÿ‘€ Show the solution
Blocks: when ๐Ÿšฉ clicked, set (score) to (0), repeat (3), say (join Your score:  score)
We answered right, then wrong, then right: 2 points
We answered right, then wrong, then right: 2 points
Finished the lesson? Mark it so your progress counts.