1. Practice tasks 1 Answers
Tasks
Write code to repetitively show ‘Hello’, one character at a time.
Write code to repetitively scroll ‘microbit’.
Write code to repetitively display a heart and a giraffe.
Write code to repetitively display 3 different shapes using a list.
Write code to repetitively scroll the numbers 1 to 9 using a for-loop.
Write code to repetitively scroll the numbers 5 to 0 using a for-loop.
Write code to repetitively scroll the numbers from the list 2, 3, 5, 7, 11, 13, 17, 19 via a for-loop.
Write code to repetitively scroll the numbers 1 to 9 using a for-loop using the range function.
Write code to repetitively show ‘Hello’, one character at a time.
from microbit import *
while True:
display.show('Hello')
Write code to repetitively scroll ‘microbit’.
from microbit import *
while True:
display.scroll('microbit')
Write code to repetitively display a heart and a giraffe.
from microbit import *
while True:
display.show(Image.HEART)
sleep(50)
display.show(Image.GIRAFFE)
sleep(50)
Write code to repetitively display 3 different shapes using a list.
from microbit import *
while True:
display.show([Image.SQUARE, Image.DIAMOND, Image.TRIANGLE])
Write code to repetitively scroll the numbers 1 to 9 using a for-loop.
from microbit import *
while True:
for num in range(1, 10):
display.scroll(num, delay=50)
Write code to repetitively scroll the numbers 5 to 0 using a for-loop.
from microbit import *
while True:
for num in range(5, -1, -1)
display.scroll(num, delay=50)
Write code to repetitively scroll the numbers from the list 2, 3, 5, 7, 11, 13, 17, 19 via a for-loop.
from microbit import *
num_list = [2, 3, 5, 7, 11, 13, 17, 19]
while True:
for num in num_list:
display.scroll(num, delay=50)
Write code to repetitively scroll the numbers 1 to 9 using a for-loop using the range function.
from microbit import *
while True:
for num in range(1,10):
display.scroll(num, delay=50)