Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
| gf_informatik:microbit_und_roboter_programmieren:repetitionsaufgaben [2023-10-03 20:23] – [Aufgaben RB] gra | gf_informatik:microbit_und_roboter_programmieren:repetitionsaufgaben [2023-10-04 14:29] (aktuell) – [Aufgaben RD] gra | ||
|---|---|---|---|
| Zeile 124: | Zeile 124: | ||
| === Aufgaben RA === | === Aufgaben RA === | ||
| - | < | + | < |
| ++++ RA1:| | ++++ RA1:| | ||
| <code python> | <code python> | ||
| Zeile 217: | Zeile 217: | ||
| </ | </ | ||
| === Aufgaben RB === | === Aufgaben RB === | ||
| - | < | + | < |
| ++++ RB1:| | ++++ RB1:| | ||
| <code python> | <code python> | ||
| Zeile 304: | Zeile 304: | ||
| </ | </ | ||
| === Aufgaben RC === | === Aufgaben RC === | ||
| + | <nodisp 1> | ||
| + | ++++ RC1:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | import random | ||
| + | |||
| + | while True: | ||
| + | column = random.randint(0, | ||
| + | for row in range(0,5): | ||
| + | display.set_pixel(column, | ||
| + | sleep(40) | ||
| + | display.clear() | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ++++ RC2:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | import random | ||
| + | |||
| + | def shoot(a_shoots): | ||
| + | row = random.randint(0, | ||
| + | if a_shoots: | ||
| + | start_column = 0 | ||
| + | stop_column = 5 | ||
| + | step = 1 | ||
| + | else: | ||
| + | start_column = 4 | ||
| + | stop_column = -1 | ||
| + | step = -1 | ||
| + | for column in range(start_column, | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | while True: | ||
| + | if button_a.was_pressed(): | ||
| + | shoot(True) | ||
| + | if button_b.was_pressed(): | ||
| + | shoot(False) | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ++++ RC3:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | import random | ||
| + | |||
| + | def binary_to_decimal(binary_string): | ||
| + | decimal = 0 | ||
| + | place_value = 1 | ||
| + | for bit in reversed(binary_string): | ||
| + | decimal = decimal + int(bit) * place_value | ||
| + | place_value = place_value * 2 | ||
| + | return decimal | ||
| + | |||
| + | binary = '' | ||
| + | while True: | ||
| + | if button_a.was_pressed(): | ||
| + | binary = binary + ' | ||
| + | if button_b.was_pressed(): | ||
| + | binary = binary + ' | ||
| + | if pin_logo.is_touched(): | ||
| + | print(binary) | ||
| + | print(binary_to_decimal(binary)) | ||
| + | sleep(100) | ||
| + | binary = '' | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ++++ RC4:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | |||
| + | while True: | ||
| + | for i in range(0,5): | ||
| + | display.set_pixel(i, | ||
| + | sleep(100) | ||
| + | display.clear() | ||
| + | for i in range(0,5): | ||
| + | display.set_pixel(i, | ||
| + | sleep(100) | ||
| + | display.clear() | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | </ | ||
| === Aufgaben RD === | === Aufgaben RD === | ||
| + | <nodisp 1> | ||
| + | ++++ RD1:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | import random | ||
| + | |||
| + | index = 0 | ||
| + | while True: | ||
| + | if button_a.was_pressed(): | ||
| + | index = (index + 1) % 12 | ||
| + | display.show(Image.ALL_CLOCKS[index]) | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ++++ RD2:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | import random | ||
| + | |||
| + | subjekte = [" | ||
| + | verben = [" | ||
| + | adjektive = [" | ||
| + | objekte = [" | ||
| + | |||
| + | index = 0 | ||
| + | while True: | ||
| + | if button_a.was_pressed(): | ||
| + | subjekt = random.choice(subjekte) | ||
| + | verb = random.choice(verben) | ||
| + | adjektiv = random.choice(adjektive) | ||
| + | objekt = random.choice(objekte) | ||
| + | satz = "{} {} {} {}." | ||
| + | print(satz) | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ++++ RD3:| | ||
| + | <code python> | ||
| + | from microbit import * | ||
| + | |||
| + | buchstaben = [" | ||
| + | |||
| + | index = 0 | ||
| + | wort = '' | ||
| + | while True: | ||
| + | display.show(buchstaben[index]) | ||
| + | if button_a.was_pressed(): | ||
| + | index = (index + 1) % 26 | ||
| + | if button_b.was_pressed(): | ||
| + | wort = wort + buchstaben[index] | ||
| + | if pin_logo.is_touched(): | ||
| + | print(wort) | ||
| + | sleep(100) | ||
| + | wort = '' | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | |||
| + | </ | ||