You are given a box with four parameters: length, width, height, and mass. Your task is to categorize the box based on the given criteria:
Bulky: A box is considered bulky if any of the dimensions (length, width, or height) of the box is greater than or equal to (10^4) or if the volume of the box is greater than or equal to (10^9).
Heavy: A box is considered heavy if its mass is greater than or equal to 100.
Categories:
You need to implement a function categorizeBox(length, width, height, mass)
that returns the appropriate category of the box.
We’ll use simple conditional checks to determine the category of the box.
def categorizeBox(length, width, height, mass):
bulky = length >= 10**4 or width >= 10**4 or height >= 10**4 or (length * width * height) >= 10**9
heavy = mass >= 100
if bulky and heavy:
return "Both"
elif bulky:
return "Bulky"
elif heavy:
return "Heavy"
else:
return "Neither"
# Example test cases
print(categorizeBox(10000, 2, 2, 50)) # Output: Bulky
print(categorizeBox(100, 100, 100, 150)) # Output: Heavy
print(categorizeBox(10000, 10000, 1, 200)) # Output: Both
print(categorizeBox(1, 1, 1, 1)) # Output: Neither
This code efficiently categorizes the box according to the given criteria using simple conditional checks.
Got blindsided by a question you didn’t expect?
Spend too much time studying?
Or simply don’t have the time to go over all 3000 questions?