Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
gf_informatik:programmieren_ii [2025-11-20 14:22] hofgf_informatik:programmieren_ii [2026-04-08 18:16] (aktuell) hof
Zeile 1: Zeile 1:
 ====== Programmieren II: Python Grundlagen ====== ====== Programmieren II: Python Grundlagen ======
-<html><script type="module" src="https://bottom.ch/ksr/ed/bottom-editor.js"></script></html>+<html><script type="module" src="https://bottom.ch/editor/stable/bottom-editor.js"></script></html>
    
 ===== Von Struktogrammen zu Python ===== ===== Von Struktogrammen zu Python =====
Zeile 499: Zeile 499:
 === Aufgabe B1 === === Aufgabe B1 ===
  
-<code python>+<html><bottom-editor> 
 +from math import sqrt
 # 1. # 1.
 print(7777+8888) print(7777+8888)
Zeile 508: Zeile 509:
 # 4. # 4.
 print(sqrt(1764)) # ja, ist Quadratzahl print(sqrt(1764)) # ja, ist Quadratzahl
-</code>+</bottom-editor></html> 
 Bemerkung: Einzelne Werte können auch in Variablen gespeichert werden. Dann kann mit den Variablen gerechnet werden. Es macht den Code aber nur länger. Bemerkung: Einzelne Werte können auch in Variablen gespeichert werden. Dann kann mit den Variablen gerechnet werden. Es macht den Code aber nur länger.
  
 === Aufgabe B2 === === Aufgabe B2 ===
  
-<code python>+<html><bottom-editor>
 name = input("Wie heisst du?") name = input("Wie heisst du?")
 city = input("Wo wohnst du?") city = input("Wo wohnst du?")
-age  = input("Wie alt bist du?")+age  = int(input("Wie alt bist du?"))
 print(name + " wohnt in " + city + " und ist " + str(age) + " Jahre alt!") print(name + " wohnt in " + city + " und ist " + str(age) + " Jahre alt!")
-</code>+</bottom-editor></html>
  
 === Aufgabe B3 === === Aufgabe B3 ===
Zeile 527: Zeile 529:
 === Aufgabe B4 === === Aufgabe B4 ===
  
-<code python>+<html><bottom-editor> 
 +from math import sqrt
 x = 7 x = 7
 x = x*2 x = x*2
Zeile 538: Zeile 541:
  
 print(x) print(x)
-</code>+</bottom-editor></html>
  
 === Aufgabe B5 === === Aufgabe B5 ===
  
 Zählen von $0$ bis $9$: Zählen von $0$ bis $9$:
-<code python>+<html><bottom-editor>
 i = 0 i = 0
 while i < 10: while i < 10:
     print(i)     print(i)
     i = i + 1     i = i + 1
-</code>+</bottom-editor></html> 
 Zählen von $0$ bis $99$, es muss nur $10$ durch $9$ ersetzt werden. Zählen von $0$ bis $99$, es muss nur $10$ durch $9$ ersetzt werden.
-<code python>+ 
 +<html><bottom-editor>
 i = 0 i = 0
 while i < 100: while i < 100:
     print(i)     print(i)
     i = i + 1     i = i + 1
-</code>+</bottom-editor></html> 
 Beachte, Code kann auch z.B. mit `while i <= 9` geschrieben werden. Die Notation `while i < 10` hat aber den Vorteil, dass man sofort sieht, wieviele Zahlen ($10$) angezeigt werden. Natürlich muss dafür $i$ bei $0$ starten. Beachte, Code kann auch z.B. mit `while i <= 9` geschrieben werden. Die Notation `while i < 10` hat aber den Vorteil, dass man sofort sieht, wieviele Zahlen ($10$) angezeigt werden. Natürlich muss dafür $i$ bei $0$ starten.
  
 === Aufgabe B6 === === Aufgabe B6 ===
  
-<code python>+<html><bottom-editor>
 my_age_in_years = 14 my_age_in_years = 14
    
Zeile 567: Zeile 573:
 my_age_in_seconds = my_age_in_hours * 3600 my_age_in_seconds = my_age_in_hours * 3600
  
-print("I am " + str(my_age_in_years) + " years old."+print(f"I am {my_age_in_yearsyears old."
-print("I am " + str(my_age_in_days) + " day old."+print(f"I am {my_age_in_daysday old."
-print("I am " + str(my_age_in_hours) + " hours old."+print(f"I am {my_age_in_hourshours old."
-print("I am " + str(my_age_in_seconds) + " seconds old."+print(f"I am {my_age_in_secondsseconds old."
-</code>+</bottom-editor></html>
  
 ++++ ++++
Zeile 628: Zeile 634:
 === Aufgabe C1 === === Aufgabe C1 ===
  
-<code python>+<html><bottom-editor layout="split">
 from turtle import * from turtle import *
 turi = Turtle() turi = Turtle()
Zeile 638: Zeile 644:
     turi.left(90)     turi.left(90)
     sides = sides - 1     sides = sides - 1
-</code>+</bottom-editor></html>
  
 === Aufgabe C2 === === Aufgabe C2 ===
  
-<code python>+<html><bottom-editor layout="split">
 from turtle import * from turtle import *
  
Zeile 661: Zeile 667:
     monika.left(90)     monika.left(90)
     length = length - 2     length = length - 2
-</code>+</bottom-editor></html>
  
 === Aufgabe C3 === === Aufgabe C3 ===
  
-<code python>+<html><bottom-editor layout="split">
 from turtle import * from turtle import *
 t = Turtle() t = Turtle()
Zeile 674: Zeile 680:
     t.circle(radius, 180)     t.circle(radius, 180)
     radius = radius - 4     radius = radius - 4
-</code>+</bottom-editor></html>
  
 === Aufgabe C4 === === Aufgabe C4 ===
  
-<html><iframe src="https://webtigerpython.ethz.ch/?layout=%5B%22Editor%22%2C%20%22Canvas%22%5D&lang=en&full_screen=false&dark_mode=false&device=-&code=NobwRAdghgtgpmAXGGUCWEB0AHAnmAGjABMoAXKJMAMwCcB7GAAjIFdayAbOJtGbehyYAqADoRxAa3ZkmAXiYAVGdwAUASnHiAzmmI8FARgAMxpuYsBiJgBkAJxADmPfbSaSAP7QBecWnAgmAGU4NDI4HT04AH1acjR6eSYAJnNrIPoANzQ4TiZOB2c3NG1ZYhz8wr8eELCIiFK4bGjdXySAVitgrJy8gHc0WmImcp57Jx5PHz8mbAYmABF2AGMAC0coJy0IPtW0biZdfSYAPiZjRHELdxlMakE%2BqCHVI55hQ6jY%2BPpNQItpDiYbjUMiqACcxl%2B1wBZDuDyexBeUSh%2F1uwNBEJR5leSRxAFpDuFmq0EABfAC6QA%3D" allow="usb;clipboard-write" style="border: 1px solid lightgray; height: 500px; width: 100%"> +<html><bottom-editor layout="split"> 
-</iframe> +from turtle import * 
-</html>+ 
 +kurt = Turtle() 
 +kurt.speed(8) 
 + 
 +side 100      # Länge der kürzeren Seite 
 +side_ratio 2  # Soviel länger ist die längere Seite 
 +step_size 5   # Soviel wird die Länge kürzer pro Durchgang 
 + 
 +while side > 0: 
 +    kurt.forward(side * side_ratio) 
 +    kurt.left(90) 
 +    kurt.forward(side) 
 +    kurt.left(90) 
 +    side side step_size 
 +</bottom-editor></html>
 ++++ ++++
 </nodisp> </nodisp>
Zeile 778: Zeile 798:
 === Aufgabe D1 === === Aufgabe D1 ===
  
-<code python>+<html><bottom-editor>
 age = int(input("Gib dein Alter ein")) age = int(input("Gib dein Alter ein"))
  
Zeile 787: Zeile 807:
 else: else:
     print("Sirup!")     print("Sirup!")
-</code>+</bottom-editor></html>
  
 === Aufgabe D2 === === Aufgabe D2 ===
  
-<code python>+<html><bottom-editor>
 x = int(input("Gib eine Zahl ein")) x = int(input("Gib eine Zahl ein"))
  
Zeile 800: Zeile 820:
 else: else:
     print("Negativ!")     print("Negativ!")
-</code>+</bottom-editor></html>
  
 === Aufgabe D3 === === Aufgabe D3 ===
  
-<code python>+<html><bottom-editor layout="split">
 from turtle import * from turtle import *
  
 turi = Turtle() turi = Turtle()
 +turi.speed(8)
 turi.hideturtle() turi.hideturtle()
  
Zeile 839: Zeile 860:
  
 turi.end_fill()  turi.end_fill() 
-</code>+</bottom-editor></html>
  
 === Aufgabe D4 === === Aufgabe D4 ===
  
-<code python>+<html><bottom-editor>
 import random import random
  
Zeile 860: Zeile 881:
  
 print(f'Du hast {correct} von 10 Aufgaben richtig gelöst!') print(f'Du hast {correct} von 10 Aufgaben richtig gelöst!')
-</code>+</bottom-editor></html>
  
 ++++ ++++
 </nodisp> </nodisp>
  • gf_informatik/programmieren_ii.1763648550.txt.gz
  • Zuletzt geändert: 2025-11-20 14:22
  • von hof