Repetition and decisions
Warm-upHumanThe loop repeat 5 times: forward, turn right, clap is written out in full, one instruction after another. How many instructions is that?
The loop repeat 5 times: forward, turn right, clap is written out in full, one instruction after another. How many instructions is that?
Which program makes the turtle draw an equilateral triangle (three equal sides, ending where it started)?
The program repeat 6 times: forward, turn right ☐ degrees draws a regular hexagon. What number goes in the box?
Start at 5. Repeat: add 4, until the number is bigger than 30. How many times is "add 4" done?
Which of these loops never stops?
In FizzBuzz (FizzBuzz for multiples of 3 and 5; otherwise Fizz for multiples of 3; otherwise Buzz for multiples of 5; otherwise the number), which numbers from 1 to 20 are said as "Fizz"? Write them separated by commas, like {1, 2}.
Add 476 + 358 with the column method. How many times do you carry 1?
When you add two numbers with the column method, why is the carry never 2?
In Lean, run home p is where the robot ends up after following program p from home, and repeatBlock 4 [.forward, .turnRight] is the loop "repeat 4 times: forward, turn right". Which statement says that the square loop brings the robot home?
Write a function fizzbuzz(n) that returns what a player says for the number n: "FizzBuzz" for multiples of 3 and 5, otherwise "Fizz" for multiples of 3, otherwise "Buzz" for multiples of 5, otherwise the number as text (for example "7"). In Python, n % 3 == 0 is the condition "n is a multiple of 3".