Question

3. Write a function that takes, as arguments, three numbers, and returns their average. Round the...

3. Write a function that takes, as arguments, three numbers, and returns their average. Round the values to the nearest tenth. Name this function calculate Average (p1, p2, p3). For example, >>>calculate Average (2.5, 3.5, 9) average of those 3 values, using decimal division. Round the values to the nearest tenth. Name your function get Average String (p1, p2, p3). For example, >>>get Average String (1.5, 3.5, 4) should return the string “The average value is 3.0.” Your sentence must EXACTLY match

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def calculateAverage(p1,p2,p3):
    return round((p1 + p2 + p3) / 3.0,1)

def getAverageString(p1,p2,p3):
    avg = round((p1 + p2 + p3) / 3.0,1)
    return "The average value is "+str(avg)+"."


# Testing
print(calculateAverage(2.5,3.5,9))
print(getAverageString(1.5,3.5,4))

Output:

5.0 The average value is 3.0.

Note : Please comment below if you have any doubts, upvote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
3. Write a function that takes, as arguments, three numbers, and returns their average. Round the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT