Hong-Phuc Bui
2025-05-05 15943ce74c0bd11cda4ee481526c3400b895a432
vorlesung 4
2 files modified
6 files added
78 ■■■■■ changed files
02-eingabe-ausgabe/demo-try.py 9 ●●●●● patch | view | raw | blame | history
02-eingabe-ausgabe/demo-while.py 7 ●●●●● patch | view | raw | blame | history
04-schleife/README.md 2 ●●●●● patch | view | raw | blame | history
04-schleife/for-demp.py 14 ●●●●● patch | view | raw | blame | history
04-schleife/kleine-ein-mal-eins.py 20 ●●●●● patch | view | raw | blame | history
04-schleife/multiplication.py 5 ●●●●● patch | view | raw | blame | history
04-schleife/muster.py 15 ●●●●● patch | view | raw | blame | history
04-schleife/while-demo.py 6 ●●●●● patch | view | raw | blame | history
02-eingabe-ausgabe/demo-try.py
New file
@@ -0,0 +1,9 @@
try:
    a = input("a = ")
    a = int(a)
    b = input("b = ")
    b = int(b)
    c = a / b
    print(c)
except:
    print("Error")
02-eingabe-ausgabe/demo-while.py
New file
@@ -0,0 +1,7 @@
x = 0
while x > -1:
    x = x + 1
    print(x)
print(x)
04-schleife/README.md
@@ -1,7 +1,5 @@
# Schleife in Python
## While Schleife
## For Schleife
04-schleife/for-demp.py
New file
@@ -0,0 +1,14 @@
for i in range(10):
    print(i)
print(f"Wert von counter nach der Schleife:{i}")
for i in range(0, 10, 2):
    print(i)
print(f"Wert von counter nach der Schleife:{i}")
for counter in range(8, 0, -2):
    print(f"{counter} ist eine gerade Zahl")
print(f"Wert von counter nach der Schleife:{counter}")
04-schleife/kleine-ein-mal-eins.py
@@ -0,0 +1,20 @@
import random
n = 20
a = int(n * random.random()) + 1
b = int(n * random.random()) + 1
prod = a * b
guess = 0
while guess != prod:
    guess = int(input(f"Wie viel ist {a} * {b}? "))
    if guess > 0:
        if guess > prod:
            print("Zahl zu groß")
        elif guess < prod:
            print("Zahl zu klein")
    else:
        print("Das ist definitiv keine richtige Antwort!")
        #break
else:
    print("Du hast richtig gerechnet!")
04-schleife/multiplication.py
New file
@@ -0,0 +1,5 @@
for y in range(2,10):
    for x in range(1,10):
        expr = f"{y} x {x}={y*x:x}"
        print(expr)
    print('-' * len(expr))
04-schleife/muster.py
New file
@@ -0,0 +1,15 @@
ROW = 5
COL = ROW * 2 - 1
# 1. Element = Sichtbare Zeichen
# 2. Element = Trennzeichen
char = ("*", " ")
for r in range(ROW):
    line = ">"
    for c in range(COL):
        idx = (r + c) % 2
        #print(char[idx],end="")
        line = line + char[idx]
    line = f"{line}<"
    print(line)
04-schleife/while-demo.py
New file
@@ -0,0 +1,6 @@
N = 10
i = 0
while i < N:
    print(i)
    #i = i + 1