Files
INF6B/schleifen/aufgabe1.py
2025-10-01 10:46:21 +02:00

30 lines
527 B
Python

import random
#utf-8 erlaubt keine äeö
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}")