Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
| gf_informatik:programmieren_ii [2025-10-06 12:33] – hof | gf_informatik:programmieren_ii [2025-11-20 14:22] (aktuell) – hof | ||
|---|---|---|---|
| Zeile 145: | Zeile 145: | ||
| == Teil I== | == Teil I== | ||
| - | <code python> | + | <html>< |
| x = int(input(' | x = int(input(' | ||
| y = int(input(' | y = int(input(' | ||
| print(x + y) | print(x + y) | ||
| - | </code> | + | </bottom-editor></ |
| == Teil II== | == Teil II== | ||
| Einfach: | Einfach: | ||
| - | <code python> | + | <html>< |
| x = int(input(' | x = int(input(' | ||
| y = int(input(' | y = int(input(' | ||
| Zeile 162: | Zeile 162: | ||
| else: | else: | ||
| print(y) | print(y) | ||
| - | </code> | + | </bottom-editor></ |
| === Aufgabe A2 === | === Aufgabe A2 === | ||
| - | <code python> | + | <html>< |
| n = int(input(" | n = int(input(" | ||
| Zeile 174: | Zeile 174: | ||
| print(" | print(" | ||
| - | </code> | + | </bottom-editor></ |
| === Aufgabe A3 === | === Aufgabe A3 === | ||
| == Teil I == | == Teil I == | ||
| - | <code python> | + | <html>< |
| a = int(input(" | a = int(input(" | ||
| b = int(input(" | b = int(input(" | ||
| Zeile 187: | Zeile 187: | ||
| print(c) | print(c) | ||
| print(a) | print(a) | ||
| - | </code> | + | </bottom-editor></ |
| == Teil II == | == Teil II == | ||
| - | <code python> | + | <html>< |
| n = int(input(" | n = int(input(" | ||
| summe = 0 | summe = 0 | ||
| Zeile 198: | Zeile 198: | ||
| summe = summe + zahl | summe = summe + zahl | ||
| print(summe) | print(summe) | ||
| - | </code> | + | </bottom-editor></ |
| === Aufgabe A4 === | === Aufgabe A4 === | ||
| - | TBD | + | < |
| + | zahl = int(input(" | ||
| + | kandidat = 2 | ||
| + | while kandidat < zahl: | ||
| + | a = zahl | ||
| + | b = kandidat | ||
| + | while b <= a: | ||
| + | a = a - b | ||
| + | if a == 0: | ||
| + | print(" | ||
| + | quit() | ||
| + | kandidat = kandidat + 1 | ||
| + | print(" | ||
| + | </ | ||
| ++++ | ++++ | ||
| Zeile 576: | Zeile 590: | ||
| Kannst du auch eine Spirale zeichnen? Beim Quadrat bleiben Seitenlänge und Winkel immer gleich - welcher der beiden Werte ändert sich bei der Spirale? | Kannst du auch eine Spirale zeichnen? Beim Quadrat bleiben Seitenlänge und Winkel immer gleich - welcher der beiden Werte ändert sich bei der Spirale? | ||
| - | Zeichne erst eine Spirale. Zeichne dann ein zweite Spirale ähnlich wie im Bild. Zeichne dazu mit einer while-Schleife die eine. Versetze dann die Position deiner Turtle mit `setX` und `setY` (oder `setPos`) | + | Zeichne erst eine Spirale. Zeichne dann ein zweite Spirale ähnlich wie im Bild. Zeichne dazu mit einer while-Schleife die eine. Versetze dann die Position deiner Turtle mit `teleport` und zeichne die Zweite Spirale mit einer neuen while-Schleife. |
| {{ : gf_informatik: | {{ : gf_informatik: | ||
| - | < | + | < |
| ++++Tipps| | ++++Tipps| | ||
| Zeile 615: | Zeile 629: | ||
| <code python> | <code python> | ||
| - | from gturtle | + | from turtle |
| turi = Turtle() | turi = Turtle() | ||
| - | turi.hideTurtle() | + | turi.hideturtle() |
| - | i = 0 | + | sides = 4 |
| - | while i < 4: | + | while sides > 0: |
| - | turi.forward(200) | + | turi.forward(100) |
| turi.left(90) | turi.left(90) | ||
| + | sides = sides - 1 | ||
| </ | </ | ||
| Zeile 628: | Zeile 643: | ||
| <code python> | <code python> | ||
| - | from gturtle | + | from turtle |
| monika = Turtle() | monika = Turtle() | ||
| - | monika.hideTurtle() | + | monika.hideturtle() |
| - | monika.setPos(-200,0) | + | monika.teleport(-100,0) |
| - | i = 0 | + | length |
| - | while i < 39: | + | while length > 0: |
| - | monika.forward(10*i) | + | monika.forward(length) |
| monika.left(90) | monika.left(90) | ||
| - | | + | |
| | | ||
| - | monika.setPos(200,0) | + | monika.teleport(100,0) |
| - | i = 0 | + | length |
| - | while i < 96: | + | while length > 0: |
| - | monika.forward(4*i) | + | monika.forward(length) |
| monika.left(90) | monika.left(90) | ||
| - | | + | |
| </ | </ | ||
| Zeile 651: | Zeile 666: | ||
| <code python> | <code python> | ||
| - | from gturtle | + | from turtle |
| t = Turtle() | t = Turtle() | ||
| - | t.hideTurtle() | + | t.hideturtle() |
| - | i = 0 | + | radius |
| - | l = 5 | + | while radius > 0: |
| - | while i < 150: | + | t.circle(radius, 180) |
| - | t.rightArc(l,20) | + | |
| - | | + | |
| - | i = i + 1 | + | |
| </ | </ | ||
| === Aufgabe C4 === | === Aufgabe C4 === | ||
| - | < | + | <html>< |
| - | </code> | + | </iframe> |
| + | </ | ||
| ++++ | ++++ | ||
| </ | </ | ||
| Zeile 677: | Zeile 690: | ||
| Bei diesen Aufgaben geht es um folgendes: | Bei diesen Aufgaben geht es um folgendes: | ||
| - | | + | |
| * etwas längere Programme schreiben | * etwas längere Programme schreiben | ||
| Zeile 725: | Zeile 738: | ||
| == Schritt 2 == | == Schritt 2 == | ||
| - | Erweitere nun dein Mathe-Quiz. In diesem soll die Aufgabe per Zufall generiert werden. Nutze den Zufallsgenerator von Python, um die beiden Zahlen, die addiert werden sollen, zufällig zu wählen. | + | Erweitere nun dein Mathe-Quiz. In diesem soll die Aufgabe per Zufall generiert werden. Nutze den [[# |
| Dazu musst du das // | Dazu musst du das // | ||
| Zeile 831: | Zeile 844: | ||
| <code python> | <code python> | ||
| + | import random | ||
| + | |||
| + | questions = 0 | ||
| + | correct = 0 | ||
| + | |||
| + | while questions < 10: | ||
| + | questions = questions + 1 | ||
| + | |||
| + | x = random.randint(1, | ||
| + | y = random.randint(1, | ||
| + | result = x + y | ||
| + | answer = int(input(f' | ||
| + | if answer == result: | ||
| + | correct = correct + 1 | ||
| + | |||
| + | print(f' | ||
| </ | </ | ||
| ++++ | ++++ | ||
| </ | </ | ||