Hong-Phuc Bui
2 days ago bf0dd3f17baf1b4c655b823f9b9c1f0b0364a503
2. Vorlesung
2 files added
62 ■■■■■ changed files
02-eingabe-ausgabe/Inhalt.md 30 ●●●●● patch | view | raw | blame | history
02-eingabe-ausgabe/gauss-ostern.py 32 ●●●●● patch | view | raw | blame | history
02-eingabe-ausgabe/Inhalt.md
New file
@@ -0,0 +1,30 @@
# Entscheidung treffen
```python
if os <= 31:
    tag = os
    monat = "März"
else:
    tag = os-31
    monat = "April"
```
# Wiederholung
## Die `while`-Schleife
```python
while not eingabe_ok:
    # ...
```
# Ausnahmesituation mit `try`-`except
```python
try:
    jahr_input = input("Geben Sie die Jahresnummer ein")
    x = int(jahr_input)
    eingabe_ok = True
except:
    print("Eingabe ist keine Zahl")
```
02-eingabe-ausgabe/gauss-ostern.py
New file
@@ -0,0 +1,32 @@
eingabe_ok = False
while not eingabe_ok:
    try:
        jahr_input = input("Geben Sie die Jahresnummer ein")
        x = int(jahr_input)
        eingabe_ok = True
    except:
        print("Eingabe ist keine Zahl")
a = x % 19
k = x // 100
m = 15 + (3*k + 3) // 4 - (8*k + 13) // 25
d = (19*a + m) % 30
s = 2 - (3*k + 3) // 4
r = (d + a // 11) // 29
og = 21 + d - r
sz = 7 - (x + x//4 + s) % 7
oe = 7 - (og - sz) % 7
os = (og + oe)
if os <= 31:
    tag = os
    monat = "März"
else:
    tag = os-31
    monat = "April"
print(f"Der Ostersonntag im {x} ist am {tag}ten {monat}")