Final answer:
To solve this problem, you can define a value-returning function called 'calculateEggSize' that takes the weight of an egg as a parameter. Within this function, you can use conditional statements to determine the size-category of the egg based on its weight.
Step-by-step explanation:
To solve this problem, you can define a value-returning function called 'calculateEggSize' that takes the weight of an egg as a parameter. Within this function, you can use conditional statements to determine the size-category of the egg based on its weight. Here is an example implementation:
def calculateEggSize(weight):
if weight < 42:
return 'pee-wee'
elif weight > 42 and weight <= 48:
return 'small'
elif weight > 48 and weight <= 55:
return 'medium'
elif weight > 55 and weight <= 63:
return 'large'
elif weight > 63 and weight <= 69:
return 'extra-large'
else:
return 'jumbo'
# You can test the function with a loop
while True: weight = float(input('Enter weight of the egg (-1 to exit): '))
if weight == -1:
break
egg_size = calculateEggSize(weight)
print('Egg size category:', egg_size)
print()
Learn more about calculateEggSize