How can you flip a coin without a coin? Students will create a coin flipping program to simulate a real coin toss. Students also have the option to manipulate code to create a customized game of their own.
Learning Objectives
- Apply the use of conditionals to create a coin flipping program.
What You’ll Need
Hands-on
- Device with a web browser and connection to the internet
- micro:bit (Optional)
Minds-on
- Computational thinking
- Problem-solving
Let’s create a coin flipping program to simulate a real coin toss. We’ll use icon images to represent a heads or tails result. You can run your coin flipping program on the MakeCode micro:bit simulator or a physical micro:bit.
- Coin Flipper Introduction
- Go to https://makecode.microbit.org and click on the Coin Flipper tutorial.
- How did you use a conditional in your program?
- Do you use conditionals in your everyday life? Can you think of an example?
- How might you use conditionals to program other types of games?
For Students
- When you use conditionals within a conditional, it is called a nested conditional. How might you use nested conditionals in your program?
- How might you incorporate the use of buttons other than A?
- How might you program a similar game but for a six-sided die instead of a coin?
For Teachers
- How might you make connections between conditionals in programming and conditionals in everyday life? For example: If you are thirsty, get a drink of water, or else, go and sit down.
- How might you have students create multiple iterations of the game?
- How might you use conditionals when giving instructions to students?
- For more activities with MakeCode, visit Online Learning with MakeCode, where you will find a list of helpful resources that students can access to continue their computing education outside of the classroom.