Number Guessing Game Part 1

Exercise: Number guessing game, Part 1

Below is code to have the computer choose a random number and then have the player guess it. It isn’t that cool yet! In the next few steps we’re going to make it much more like playing the guess a number game with a person!

First, make this script in Scratch.

Secret Number Original Script

Note: the “ask” block will give you an opportunity to respond with your answer.

Think about the answers to the following questions:

  1. Explain what the second line of code does. What is the variable “secret number”? What is it being set to?
  2. What do you think the “ask ____ and wait” block is waiting for? (Hint: see note above)
  3. What do you think will happen if your answer does not equal “secret number” (If you don’t guess the right number)? What will the code do? (This is a tough one — try to figure out the answer before trying it in Scratch)
X
X