At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Our Q&A platform offers a seamless experience for finding reliable answers from experts in various disciplines. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.
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. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.