PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Base expedition

Mission 8 of 13

Base expedition: Mission 8 of 14

Guess My Number


Intermediate

1 hour

Grades 3 - 8

MISSION OBJECTIVE

Learn to code a game to guess a number from your Pico.

Learn to create a random number generator and learn to make comparisons after receiving an input. This project will teach the the basics of computational thinking and coding logic.

View student interface at make.playpiper.com
MISSION CHARACTERS

Piperbot

Pip
MISSION MATERIALS

Computer with USB port and Chrome or Edge browser
Piper Make Base Station or Starter Kit

MISSION RESOURCES

Learning Goals

  1. Students will use loops, variables, and conditionals to create a game that will let them guess which number their Pico has generated.
  2. Students will understand how to use comparisons in code to determine whether a value is greater than, less than, or equal to another.
  3. Students will be able to determine if a device uses conditionals by learning about them in this activity.
I WILL BE ABLE TO...
  • Write mathematical functions (like greater than, less than, or equal to) in code
  • Use loops, variables, and conditionals to create a game that will let you guess a randomly-generated lock combination

Learning Activities

ELA Extension: Number Sleuth Mystery Writing

  • Pair students up or allow them to work independently based on writing level and creativity. Students will write a short mystery story or dramatic dialogue using clue-based logic, descriptive language, and critical thinking to narrow down a hidden number.
  • Begin by having students create a character—such as a robot detective (e.g., Pip, Piperbot) or a student sleuth—who is trying to solve a number mystery.
  • Next, students will generate 3–5 clues that logically describe the number. Examples: “It’s greater than 20 but less than 50.” “It’s even.” “It ends in 6.”
  • Students then write a story or skit in past tense, using vivid details and suspense. Encourage internal thoughts or dialogue like: “Could it be 46? No, that’s too high!” Stories should include a setting, character motivation, and what happens if they guess wrong.
  • Once finished, partners exchange stories and try to solve each other’s mystery before the ending is revealed.

Bonus vocabulary words to include: greater than, less than, equal to, range, clue, guess, logic

EXTENSION: Students create interactive mystery cards with clues for peers to solve in a gallery walk or guessing station.


ELD Extension: Secret Number Guessing Game
  • Pair students so that each English Learner (EL) is working with a fluent English speaker or a higher-level EL. Begin by reviewing key comparison terms: greater than, less than, equal to, between, before, after. Support comprehension with number lines, charts, or flashcards.
  • In pairs, students take turns thinking of a secret number within a chosen range (e.g., 1–50). The other partner guesses the number by asking yes/no questions:
    • “Is it greater than 20?”
    • “Is it even?”
    • “Is it less than 30?”
  • Students respond and track the clues to narrow down the range.
  • Support oral language development with sentence frames such as:
    • “I think your number is ___ because ___.”
    • “Your number is between ___ and ___.”
    • “It can’t be ___ because you said ___.”
  • After several rounds, students write a short journal entry about their best strategy or a clue they found confusing.

OPTIONAL CLASS GAME:
Play a whole-class version where the teacher picks a number and students take turns asking yes/no questions aloud using academic vocabulary.


Math Extension: Guess My Number – Logic & Range
  • Pair students or assign small groups based on grade level and readiness.
  • Begin by choosing a number range appropriate for your class (e.g., 1–20 for early grades, 1–100 for older students). Provide number lines or charts to help students visually eliminate guesses.
  • Each pair will take turns thinking of a secret number while the other asks yes/no questions to narrow the range. Students must use logic and eliminate options with each response.
  • Students will also track their thinking using a data table that shows:
    • Each guess
    • Clue received
    • Updated narrowed range
  • Once the number is guessed, students reflect and discuss:
    • “What was your best strategy?”
    • “How many guesses did it take?”
    • “Could you do it faster next time? Why or why not?”

EXTENSION CHALLENGE: Introduce the concept of binary search.

Ask students:
  • “What’s the fewest number of guesses possible if you always split the range in half?”
  • Have them compare binary search to random guessing and explain which is more efficient and why.

Career Connections

Software Developer: Salary $127,260/yr
Electrical Engineer: Salary $127,260/yr
Data Scientist: Salary $103,500/yr
Construction Manager: Salary $101,480/yr

Code Diagram




Tutorial Steps

Guess My Number

Help Piperbot and Pip get into the onboard safe with tools to repair the spaceship! If only they knew the code...

Oh no, how are we going to get into this safe? I know the number is between 1 and 20 but I can't remember it!
Let's generate the safe code using your Pico, and then we're going to start guessing!

Are you ready to get started? Click NEXT.

This one's easy! All we'll need is your Pico!
Once you have it ready, click NEXT.

First things first, we have to make the Pico come up with a random number right?
Hmmm let's set that value as our Pico guess. We'll have to make that a variable!
Start by dragging out a start block from the Chip menu. Then, in the Variable menu, click the Create variable button and name our new variable "pico guess".

Then, drag out the set Pico guess to block and connect it to the start block.

Finally, in the Values menu, find the random integer from block and place it in the set Pico guess to block.
Click NEXT.

Now that we have our safe code, we're going to need Pip and I to guess the code!
Ooh let's save our guess as a variable too!
Open the Variables menu, and click the Create Variable button again. Name the new variable "player guess".

Then, drag the set player guess to block and connect it to the bottom of your program:
Hold on, no way we can guess a number between to 1 to 100! Let's change that second number to 20!
Click NEXT.

We will play this game using the CONSOLE tab at the bottom of the workspace. Remember using a print block to send information to the console?
This time, we are going to use an ask block from the Chip menu to send information to the Pico. The ask block returns the text that the user types into the CONSOLE.
But wait! When you type into the console, it sends text characters back to the Pico. The problem is that a text value and a number value are not the same!
For example, "24" is a "2" character and a "4" character, and that's different than the number 24. The good news is that we can convert "24" to 24 using a number from text block in the Values menu.

Drag a number from text block into the set player guess to block:
Click NEXT.

Now we are ready to get the player's guess!
Drag an ask block from the Chip menu and place it into the number from text block.
Why does the ask block have a "_" that you can type into?
That's where you type in a question to ask!
Type "Guess a number from 1 to 20":
Then, click NEXT.

Now that we have the safe code and we know our own guess, we should just write some code to tell us if our guess was too high, too low, or if we guessed correctly!
That means we need an if block! Grab the if block from the Logic menu that already has an _ = _ block in it, and connect it to your code:
Hmm okay so if the code is 10 and we guess 8, then we want that say that we're too low, right? And if we guess 12, that's too high?
That's right! If we're not too high and we're not too low, then we must be right! This sounds like a job for an if else-if else block!
Click the blue gear icon on the if block. In the menu that pops up, drag over 1 else if block, and then drag over 1 else block:
Click the blue gear icon to close the menu, then click NEXT.

Okay let's figure out how to compare our guess to the code. using our code!
Drag a player guess block from the Variables menu to the left side of the _ = _ block. Then, drag a pico guess block from the Variables menu to the right side of that block. Finally, change the = to a < (less than).

Duplicate the _ < _ block and drag it into the else if condition. Change the < (less than) to > (greater than):
Click NEXT.

Okay but how are we going to know if we guessed too high or low? We need to print that right?
Let's make print blocks that say "Too low", "Too high", and "You won!". You can find the print block in the Chip menu. Where should those blocks go in our if else-if else statement?
Did you get the print blocks added in? If so, click NEXT.

Let's try out our game! Do you think it will work?
Since this game is played using the CONSOLE, click the CONSOLE tab at the bottom of the workspace to open it up.

Next, click CONNECT, then click START.

You should see this in the CONSOLE:
Guess a number from 1 to 20:?
Before you can type in the CONSOLE, you have to click it. When you do, the cursor will start blinking, which means that it is ready for you to type in a number!
Type a number between 1 and 20, and then press Enter or Return on your keyboard.

Click NEXT.

Did it work? Did our game tell you if your guess was too high or too low? Were we lucky enough to win?
Any of the above could have happened, but after one guess, your program stopped!
What would you guess is the next step?
Write a function to speed up the comparisons
Add in some sound effects!
Add a loop to allow us to continue guessing
Use our sensing panel to put a sensor into the mix

Click NEXT to find out the answer!

If we want to keep guessing, we want to loop back to rewrite the variable that is storing our guess!
Grab the set player guess to block in your program and pull it away from the set Pico guess to block.

Then, drag out a repeat forever block from the Loops menu and connect it to the set Pico guess to block. Finally, put all of the blocks inside of the repeat forever block:
Click NEXT.

Let's do it! Click START to play the game, and once you've gotten the right answer, maybe we can use it to open our safe!
Click NEXT when you win!

Boo! Even after I won, the game asked me to guess again! How can we fix that?
After we win, we need to exit out of the loop. We can do this by adding an exit block from the Loops menu right after the print "You won!" block:
Let's also turn on the Pico's LED so we know when we opened the safe
Add a turn pin block and set to to turn pin GP25 HIGH when we guess the correct number. Then, add a wait 2 seconds block to make it stay on for a little while before the program ends:
Try your game again by clicking START. After you win, click NEXT.

Sweet, we did it! Let's try that code out on our safe!
What are some ways to change it up? Could we change our code to guess for us instead of having to input our own answers?

When you're ready to try some new tutorials or projects, click EXIT to go back to the start screen.

Blueprint

OPEN IN BLUEPRINT VIEWER  DOWNLOAD

Have an different version? Look for more information on the Support Page.

Troubleshooting Tips

  • Are the number comparisons incorrect? Is your program saying 2 is greater than 5?
    • Ensure the directionality of your greater than (>) or lesser than (<) signs are arranged correctly.
  • What does Pico Guess indicate?
    • Pico Guess is a variable that stores a randomly generated number as coded for in the first line. When you click START, a new number is generated and stored in the variable.

Our customer support specialists are on hand to ensure your implementation of Piper runs seamlessly.
View Support Docs or Contact Support
EXPANDED RESOURCES

Term Glossary


Circuit A conductive path for the flow of current or electricity.

Power The current or flow of electric charge and voltage.

Microcontroller An integrated circuit containing a microprocessor with memory and associated circuits.

Variables A value that can change depending on conditions or information passed to the program. A storage location with a symbolic name used to keep track of a value that can change while a program is running (similar concept to using X and Y in an algebraic equation). Variables are not only numbers; they can also hold text, including whole sentences (strings) or logical values (true or false).

Input Device A hardware device that sends data to a computer, allowing interaction and control.

Output Device A piece of hardware that converts information into a form humans can sense and understand.

View Full Glossary

Standards Alignment