At the end of this lesson, you will be able to:
understand and use an if statement
sequential programs
sequential flowcharts
all our programs so far have been linear
go over if-then flowchart (see below)
go over "Boolean Expression" and "If ... Then" (see videos below)
go over "Random Numbers"
in TypeScript:
randomNumber = randint(0, 1)
in Python:
from random import *
random_number = randint(0, 1) # Pick a random number between 0 and 1.
recreate my "Random Number" program
click on provided link to create a new GitHub repo
call the repo: TEJ2O.1-Unit2-09
review the Rock, Paper, Scissor game:
get in your pairs and write a Micro:Bit program that you can each load onto your Micro:Bits
when you shake the Micro:Bit it will pick a number between 0 - 2, but show the corresponding rock - paper - scissor icon and stays on screen for 5 seconds
if you won, hit the "A" button to add 1 to your score
if you hit "B" it will tell you your score
see demo app below
you CAN ONLY use if statements (NO if ... then ... else!)
do the above assignment but in Python
Only watch up to 1:36
"Shake" the Micro:Bit to run program.
"Shake the Micro:Bit it will pick a number between 0 - 2, but show the corresponding rock - paper - scissor icon. Hold the icon on the screen for 5 seconds, so each of you can compare and decide who wins.
If you won, hit the "A" button to add 1 to your score.
If you hit "B" it will tell you your score.