Choose a delivery window
A local courier chooses service by parcel weight. Print BIKE for weights up to 2 kg, VAN for weights over 2 kg and up to 20 kg, and FREIGHT for anything heavier.
Input
One line: a decimal parcel weight in kilograms.
Output
One line: BIKE, VAN or FREIGHT.
Example 1
Input
7.5
Output
VAN
7.5 is above 2 and no more than 20.
Constraints
- 0 < weight <= 500
Hints
Hint 1 of 3
Test the smallest upper boundary first.
Hint 2 of 3
After weight <= 2 fails, the next branch only needs weight <= 20.
Hint 3 of 3
Use if, elif and else so exactly one label prints.
Solution
Show a reference solution and explanation
weight = float(input())
if weight <= 2:
print("BIKE")
elif weight <= 20:
print("VAN")
else:
print("FREIGHT")
Why it works
Ordered upper-bound checks avoid overlapping logic. Reaching the second condition already proves the weight is above two, and the final else covers every remaining heavier parcel.
Lesson for this exercise: Conditions: if, elif and else in Python