Skip to content
Snippets Groups Projects
Commit a97dadc5 authored by William Dos Santos's avatar William Dos Santos
Browse files

Added

parent 362f4ca4
No related branches found
No related tags found
No related merge requests found
Ähnliche Aufgaben wie auf Moodle
Aufgabe:
Schreiben Sie eine Funktion namens shipping_cost_calculator, die die Parameter order_weight (in kg) und shipping_zone (als String: "local", "national", "international") akzeptiert. Die Funktion soll die gesamten Versandkosten basierend auf den folgenden Regeln zurückgeben:
Versandkosten-Regeln:
Local:
Bis 2 kg: 5€ | 2 bis 5 kg: 10€ | Mehr als 5 kg: 15€
National:
Bis 2 kg: 10€ | 2 bis 5 kg: 20€ | Mehr als 5 kg: 30€
International:
Bis 2 kg: 20€ | 2 bis 5 kg: 40€ | Mehr als 5 kg: 60€
Code:
# Prüfcode
def test_shipping_cost_calculator():
# Testfälle für Local
assert shipping_cost_calculator(1, "local") == 5
assert shipping_cost_calculator(3, "local") == 10
assert shipping_cost_calculator(6, "local") == 15
# Testfälle für National
assert shipping_cost_calculator(1, "national") == 10
assert shipping_cost_calculator(3, "national") == 20
assert shipping_cost_calculator(6, "national") == 30
# Testfälle für International
assert shipping_cost_calculator(1, "international") == 20
assert shipping_cost_calculator(3, "international") == 40
assert shipping_cost_calculator(6, "international") == 60
# Test für ungültige Eingaben
try:
shipping_cost_calculator(3, "unknown")
except ValueError as e:
assert str(e) == "Ungültige Versandzone"
else:
assert False, "Es wurde keine Ausnahme für ungültige Eingaben geworfen"
# Tests ausführen
test_shipping_cost_calculator()
print("Alle Tests bestanden!")
\ No newline at end of file
ID;Name;Type;Speed;Lifespan;Weight 1;Cheetah;Mammal;93;12;72 2;Elephant;Mammal;25;70;5400 3;Peregrine Falcon;Bird;240;15;1.5 4;Lion;Mammal;80;15;190 5;Rabbit;Mammal;48;8;2 6;Ostrich;Bird;70;45;150 7;Horse;Mammal;88;30;500
{
"folders": [
{
"path": "."
}
]
}
\ No newline at end of file
[
{
"sensor_id": "S1",
"temperature": 21.1,
"humidity": null,
"pressure": 1012.4
},
{
"sensor_id": "S2",
"temperature": null,
"humidity": 45.2,
"pressure": null
},
{
"sensor_id": "S3",
"temperature": 18.3,
"humidity": null,
"pressure": 1008.8
},
{
"sensor_id": "S4",
"temperature": null,
"humidity": null,
"pressure": null
}
]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment