Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
capacity = float(input("Van capacity (kg): "))
load = 0.0
while True:
package_weight = float(input("Next package kg (0 to finish): "))
if package_weight == 0:
break
if load + package_weight > capacity:
print("Overloaded - cannot load")
break
load += package_weight
print("Final load (kg):", load)
if load >= capacity:
print("At or above capacity.")
else:
print("Under capacity.")