Get reliable answers to your questions at Westonci.ca, where our knowledgeable community is always ready to help. Discover in-depth answers to your questions from a wide network of experts on our user-friendly Q&A platform. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.
Sagot :
See comment for program requirements:
Answer:
The function in Python is as follows:
def hungryDog(weight,age):
if age >= 1:
if weight <= 5:
feed = 0.05 * weight
elif weight >= 6 and weight <= 10:
feed = 0.04 * weight
elif weight >= 11 and weight <= 15:
feed = 0.03 * weight
else:
feed = 0.02 * weight
else:
if weight >= 0.167 and weight <= 0.333:
feed = 0.10 * weight
elif weight > 0.333 and weight <= 0.583:
feed = 0.05 * weight
elif weight > 0.583:
feed = 0.04 * weight
return feed
Explanation:
This defines the function
def hungryDog(weight,age):
If age is 1 and above
if age >= 1:
If weight is less than 5
if weight <= 5:
Feed is 5% of weight
feed = 0.05 * weight
if weight is between 6 and 10
elif weight >= 6 and weight <= 10:
Feed is 4% of weight
feed = 0.04 * weight
if weight is between 11 and 15
elif weight >= 11 and weight <= 15:
Feed is 3% of weight
feed = 0.03 * weight
If weight is above 15
else:
Feed is 2% of weight
feed = 0.02 * weight
If age is less than 1
else:
If weight is between 2 and 4 months
if weight >= 0.167 and weight <= 0.333:
Feed is 10% of weight
feed = 0.10 * weight
If weight is between 4 and 7 months
elif weight > 0.333 and weight <= 0.583:
Feed is 5% of weight
feed = 0.05 * weight
If weight is above 7 months
elif weight > 0.583:
Feed is 4% of weight
feed = 0.04 * weight
This returns the feed
return feed
We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.