initial commit

This commit is contained in:
2025-10-01 10:46:21 +02:00
commit 50a55e19d6
138 changed files with 2037 additions and 0 deletions

30
schleifen/aufgabe1.py Normal file
View File

@@ -0,0 +1,30 @@
import random
#utf-8 erlaubt keine <20>e<EFBFBD>
weight = {
"Kirsche": 8,
"Orange": 5,
"Zitrone": 5,
"Apfel": 7,
}
count = {
"Kirsche": 0,
"Orange": 0,
"Zitrone": 0,
"Apfel": 0,
}
total_weight = 0
target_weight = 250
while total_weight < target_weight - 5:
fruit = random.choice(list(weight.keys()))
total_weight += weight[fruit]
count[fruit] += 1
print("Zusammensetzung")
for fruit, amount in count.items():
print(f"{fruit}: {amount} Stueck")
print(f"Gesamtgewicht: {total_weight}")