Example: air traffic controller

Python プログラム集~

Micro:bit Python .. 1 micro:bit .. 1 .. 1 .. 1 .. 2 .. 2 .. 2 .. 3 .. 4 10 2 .. 4 .. 5 .. 5 micro:bit .. 5 .. 5 .. 6 .. 6 .. 7 .. 7 .. 7 .. 7 .. 8 .. 8 .. 9 .. 10 .. 10 .. 10 .. 11 .. 12 .. 12 .. 13 .. 14 .. 14 .. 14 .. 15 .. 16 .. 16 .. 16 .. 16 3.

2 【練習. 1-4】 プログラムなし. 演習問題 (1) (保存ファイル名: microbit- ens1-1) for x in range(5): for y in range(5): if x == y:

Tags:

  Python, Microbit

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Python プログラム集~

1 Micro:bit Python .. 1 micro:bit .. 1 .. 1 .. 1 .. 2 .. 2 .. 2 .. 3 .. 4 10 2 .. 4 .. 5 .. 5 micro:bit .. 5 .. 5 .. 6 .. 6 .. 7 .. 7 .. 7 .. 7 .. 8 .. 8 .. 9 .. 10 .. 10 .. 10 .. 11 .. 12 .. 12 .. 13 .. 14 .. 14 .. 14 .. 15 .. 16 .. 16 .. 16 .. 16 3.

2 17 .. 17 .. 18 JavaScript micor:bit JavaScript JavaScript micro:bit JavaScript Python rei JavaScript microbit -rei .hex JavaScript 2019 3 Python 2020 2020 6 12 micor:bit Python Python JavaScript Python 5 6 7 Python 2020 6 MicroPython MicroPyhon Python MicroPyhon JavaScript (2019 3 ) Pyt hon Python MicroPyhon JavaScript Python 1) micro:bit Web micro.

3 Bit 2) BBC BP ( ) 1 micro:bit 1-1 ( microbit -rei1-1-1) (""" . # . # . # # # # # # # # # # . # # # .. # .. """) ( microbit -rei1-1-2) def on_forever(): (""" . # . # . # # # # # # # # # # . # # # .. # .. """) (500) () (500) (on_forever) 1-2 ( microbit -rei1-2) (2, 0) (2, 1) (2, 2) (2, 3) (2, 4) 1-3 ( microbit -rei1-3) for y in range(5): (2, y) 1-1 ( microbit -ren1-1) for x in range(5): (x, 2) 1-4 ( microbit -rei1-4) for x in range(5): (x, 4 - x) 1-2 ( microbit -ren1-2) for x in range(5): (x, x) 1-3 ( microbit -ren1-3-1) for x in range(5): (x, x) for y in range(5): (y, 4 - y) ( microbit -ren1-3-2) for x in range(5): (x, x) (x, 4 - x) 1-5 ( microbit -rei1-5) for x in range(5): for y in range(5).

4 (x, y) (100) 1-6 ( microbit -rei1-6) x = 0 while x <= 4: (x, 4 - x) x += 1 1-7 ( microbit -rei1-7) c = 0 def on_forever(): global c c = randint(0, 1) (c) if c == 0: ( ) else: ( ) (on_forever) 1-8 ( microbit -rei1-8) c = 0 def on_forever(): global c c = randint(0, 2) (c) if c == 0: ( ) elif c == 1: ( ) else: ( ) (on_forever) 2 1-4 (1) ( microbit -ens1-1) for x in range(5): for y in range(5): if x == y: (x, y) (100) (2)(a) ( microbit -ens1-2-1) for x in range(5): for y in range(5): if 4 - x <= y: (x, y) (500) (2)(b) ( microbit -ens1-2-2) for x in range(5): for y in range(5): if x == y or 4 - x == y: (x, y) (500) (2)(c) ( microbit -ens1-2-3) for x in range(5): for y in range(5): if x == 2 or y == 2: (x, y) (500) (3) ( microbit -ens1-3) c = 0 def on_gesture_shake(): global c c = randint(0, 2) (c) if c == 0: ( ) elif c == 1: ( ) else.

5 ( ) ( , on_gesture_shake) 2-1 ( microbit -rei2-1) a = 0 b = 0 c = 0 def on_button_pressed_a(): global a, c a = randint(0, 2) (a) c = a hyouji() ( ,on_button_pressed_a) def on_button_pressed_b(): global b, c b = randint(0, 2) (b) c = b hyouji() ( , on_button_pressed_b) def hyouji(): if c == 0: (IconNames. SMALL_DIAMOND) elif c == 1: ( ) else: ( ) 2-2 ( microbit -rei2-2) a = 0 b = 0 c = 0 d = 0 def on_button_pressed_a(): global a, c a = randint(0, 2) c = a hyouji() ( , on_button_pressed_a) def on_button_pressed_ab(): global d d = (a - b + 3) % 3 if d == 2: ("A") elif d == 1: 3 ("B") else: ("AB") ( , on_button_pressed_ab) def on_button_pressed_b(): global b, c b = randint(0, 2) c = b hyouji() ( , on_button_pressed_b) 2-1 ( microbit -ren2-1) a = 0 b = 0 c = 0 d = 0 def on_button_pressed_a().

6 Global a, c a = randint(0, 2) c = a hyouji() ( , on_button_pressed_a) def on_button_pressed_ab(): global d d = (a - b + 3) % 3 if d == 2: ("A" + "Kati") elif d == 1: ("B" + "Kati") else: ("Hikiwake") ( , on_button_pressed_ab) def on_button_pressed_b(): global b, c b = randint(0, 2) c = b hyouji() ( , on_button_pressed_b) def hyouji(): if c == 0: ( ) elif c == 1: ( ) else: ( ) () 2-3 ( microbit -rei2-3) kouho = 0 kotae = 0 kotae = randint(0, 2) (kotae) def on_button_pressed_a(): global kouho kouho = randint(0, 2) (kouho) ( , on_button_pressed_a) def on_button_pressed_b(): if kouho == kotae: ( ) else: ( ) ( , on_button_pressed_b) 2-4 ( microbit -rei2-4) kouho = 0 kotae = 0 kotae = randint(0, 4) (kotae) kouho = randint(0, 4) (kouho) hantei() def hantei(): if kouho > kotae: ( ) () elif kouho < kotae: ( ) () else: (kouho) () ("Hit") def on_button_pressed_a(): global kouho kouho += 1 hantei() ( , on_button_pressed_a) def on_button_pressed_b().

7 Global kouho kouho += -1 hantei() 4 ( , on_button_pressed_b) 2-2 ( microbit -ren2-2) kouho = 0 kotae = 0 kotae = randint(0, 4) if kouho == kotae: kouho = randint(0, 4) (kouho) hantei() def hantei(): if kouho > kotae: ( ) () elif kouho < kotae: ( ) () else: (kouho) () ("Hit") def on_button_pressed_a(): global kouho kouho += 1 hantei() ( , on_button_pressed_a) def on_button_pressed_b(): global kouho kouho += -1 hantei() ( , on_button_pressed_b) 2-5 ( microbit -rei2-5) a = [3, 2, 1, 5, 4] for i in range(5): (a[i]) () for y in range(5): x = 0 while x <= a[y] - 1: (x, y) x += 1 ( microbit -c23-kansu) c = 0 c = sum(3, 5) ("3+5=") (c) def sum(a: number, b: number): s = 0 s = a + b return s 2-3 ( microbit -ren2-3-1) a: List[number] = [] x = 0 a[ 0] = 3 a[ 1] = 2 a[ 2] = 1 a[ 3] = 5 a[ 4] = 4 for z in range(5): (a[z]) ( microbit -ren2-3-2) let a: number[] = [] a[ 0] = 3, a[ 1] = 2, a[ 2] = 1, a[ 3] = 5, a[ 4] = 4 for (let z = 0; z <= 4.)

8 Z++) { (a[z]) } 2-4 ( microbit -ren2-4) a: List[number] = [] a = [1, 2] b: List[str] = [] b = ["AB", "cd"] for i in range(2): (a[i]) () for j in range(2): ("" + b[j]) 2-6 ( microbit -rei2-6) y = 0 a = [3, 2, 1, 5, 4] for x in range(5): z = 0 while z <= a[x] - 1: y = 4 - z (x, y) (500) z += 1 10 2 2-7 ( microbit -rei2-7) 5 xp: List[number] = [] xp = [0, 0, 0, 0, 0] for k in range(32): DtoB(k) def DtoB(k: number): j = 4 while j >= 0: xp[j] = k % 2 k = (k / 2) j -= 1 Plot() def Plot(): i = 4 while i >= 0: if xp[i] == 1: x = i for y in range(5): (x, y) i -= 1 (1000) () (1) ( microbit -ens2-1) y2 = 0 a: List[number] = [] a = [3, 2, 1, 5, 4] plot() def plot(): Graph_H() () Graph_V() def Graph_V(): global y2 for x in range(5): z = 0 while z <= a[x] - 1: y2 = 4 - z (x, y2) (500) def Graph_H(): for y in range(5): x2 = 0 while x2 <= a[y] - 1: (x2, y) (500) x2 += 1 z += 1 (2) ( microbit -ens2-2) x = 0 y = 0 a: List[number] = [] a = [3, 2, 1, 5, 4] plot(0) () plot(1) def plot(g: number).

9 Global y if g == 0: for z in range(5): b = 0 while b <= a[z] - 1: (b, z) (500) b += 1 else: for c in range(5): d = 0 while d <= a[c] - 1: y = 4 - d (c, y) (500) d += 1 micro:bit 3-1 ( microbit -rei3-1) def on_forever(): ( ()) () (1000) (on_forever) 3-1 ( microbit -ren3-1) def on_forever(): ( ( )) () (1000) (on_forever) 3-2 ( microbit -rei3-2) def on_forever(): (262, ( )) 6 (294, ( )) (330, ( )) ( ( )) (on_forever) 3-2 ( microbit -ren3-2) def on_forever(): (262, ( )) (262 * 2, ( )) (262 * 4, ( )) (on_forever) 3-3 ( microbit -ren3-3) def on_forever(): (262, ( )) (262 * 2, ( )) (262 * 3, ( )) (262 * 4, ( )) (262 * 5, ( )) (523, ( )) (523 * 2, ( )) (523 * 3, ( )) (on_forever) 3-3 ( microbit -rei3-3) def on_button_pressed_a(): ( ( ), ) ( , on_button_pressed_a) 3-4 ( microbit -ren3-4) def on_button_pressed_a(): ( ( ), ) ( , on_button_pressed_a) def on_button_pressed_b().

10 ( ( ), ) ( , on_button_pressed_b) 3-4 ( microbit -rei3-4) def on_forever(): if ( ) < -10: (262) elif ( ) > 10: (294) else: ( ( )) (on_forever) 3-5 ( microbit -ren3-5) def on_forever(): (2 * ( ) + 262) (on_fo)


Related search queries