Search Header Logo
Rock-paper-scissors (microbit)

Rock-paper-scissors (microbit)

Assessment

Presentation

Computers

9th Grade

Practice Problem

Hard

Created by

Andy tsui

Used 1K+ times

FREE Resource

11 Slides • 11 Questions

1

Rock-paper-scissors (microbit)

Slide image

2

Objectives

  • Define and use variables

  • Variable data types

  • Storing input to variable

  • Conditional Statement

3

What is variable?

  • Store value in computer program

  • The value can be coming from input, results of calculations or just anything you want to store



4

Try defining variables in REPL mode

5

Fill in the Blank

What is the value of variable A, after all the following code executed.


A = 10

6

Fill in the Blank

What is the value of variable B, after all the following code executed.


A = 5

B = 10

C = 11

7

Fill in the Blank

What is the value of variable B, after all the following code executed.


A = 5

B = 10

A = A + B

8

Fill in the Blank

What is the value of variable A, after all the following code executed.


B = 10

C = 2 + 3

9

Variable types

  • Each variable, when defined, will be assigned a data type

  • There are a few data types in Python:

10

Types in python

  • int or integer

  • float, which stores numbers with decimals

  • string, for text, note when referring to string, we need to put a pair of double quote, e.g. "This is string", "10"

  • bool, stands for boolean

11

Boolean

  • Boolean is a special type that allows two possible values only: True and False

  • Boolean is for logical statement



12

Multiple Choice

What is the data type for the following variable A:


A = 15

1

int

2

float

3

string

4

boolean

13

Multiple Choice

What is the data type for the following variable A:


A = 1.5

1

int

2

float

3

string

4

boolean

14

Multiple Choice

What is the data type for the following variable A:


A = "15"

1

int

2

float

3

string

4

boolean

15

Multiple Choice

What is the data type for the following variable A:


A = True

1

int

2

float

3

string

4

boolean

16

Multiple Choice

What is the data type for the following variable A:


A = 3 > 4

1

int

2

float

3

string

4

boolean

17

Getting button press in Microbit

Try in REPL mode

18

Open Ended

Quick Review:


What is the command if we want to output a string "X" on the microbit LEDs?

19

Rock paper scissors device - 1

  • IF Button A is pressed, then display "R"

  • IF Button B is pressed, then display "P"


20

Open Ended

What is the logical statement, if we want to know if both button A and B is pressed?

21

Now complete the Program

also Add Press A+B will display "S"

22

Extended Activity

  • Try, instead of displaying text, display an image to represent Rock paper and scissors

  • Refer to the following document:

  • https://microbit-micropython.readthedocs.io/en/stable/tutorials/images.html

Rock-paper-scissors (microbit)

Slide image

Show answer

Auto Play

Slide 1 / 22

SLIDE