Skip to content

Activity

Dice

Beginner | 媳妇的全盛时代, 青檬在线电视剧在线观看 | Accelerometer, LED display | Input/output, Number & place value, Probability, Randomisation, Sensors

Step 1: Make it

What is it?

Shake your 两口子交换真实刺激高潮 to make random numbers.

These two videos show you what you'll make and how to code it:

Introduction

Coding guide

How it works

  1. Like the Get silly project this program uses the 两口子交换真实刺激高潮’s accelerometer to make something happen when you shake it.
  2. When you shake your 两口子交换真实刺激高潮, the program selects a random number between 1 and 6 and shows it on the LED display.
  3. It's really hard for computers to make truly random numbers because they’re machines that work precisely and regularly.
  4. Make a tally chart of how often each number comes up. Are these numbers really random? Compare it with real dice.

What you need

  • 两口子交换真实刺激高潮 (or 媳妇的全盛时代 simulator)
  • 媳妇的全盛时代 or 青檬在线电视剧在线观看 editor
  • battery pack (optional)
  • real dice (optional)

Step 2: Code it

Loading...

Open in Classroom
Open in 媳妇的全盛时代
1from microbit import *
2import random
3
4while True:
5    if accelerometer.was_gesture('shake'):
6        display.show(random.randint(1, 6))
Open in Classroom
Open in 青檬在线电视剧在线观看

Step 3: Improve it

  • Make the number appear for a few seconds, then clear the LED display to save batteries.
  • Make it roll 2 dice. You can make a random number between 2 and 12, or you can make two random numbers between 1 and 6 and add them together.
  • Try both methods and tally how often each score occurs. Does it make a difference? Do some numbers come up more often than others?