Ask Question
4 March, 10:37

Write a program that estimates the approximate number of times the user's heart has beat in his/her lifetime using an average heart rate of 72 beats per minute and estimates the number of times the person has yawned in his/her lifetime using an average of 5 yawns per day. The program should have two functions, heartbeats (age) and yawns (age), that take age in years as an input parameter and returns the estimated number of heartbeats and the number of yawns, respectively. In your computation ignore the leap years.

+2
Answers (1)
  1. 4 March, 11:57
    0
    The code snippet given in python for resolve this question is the following:

    import datetime

    currentYear = datetime. date. today (). year

    def heartbeats (age):

    av = 72 * 60 * 24 * 365

    for i in range (currentYear - age - 1, currentYear + 1):

    if is_leap (i):

    av + = av

    else:

    pass

    return av

    def yawns (age):

    av = 5 * 365

    for i in range (currentYear - age - 1, currentYear + 1):

    if is_leap (i):

    av + = av

    else:

    pass

    return av

    def is_leap (year):

    if ((year%400 = = 0) or ((year%4 = = 0) and (year%100! = 0))):

    return True

    else:

    return False

    print ("Heartbeats: {}, yawns: {}". format (heartbeats (23), yawns (23)))

    Explanation:

    We have defined 3 functions:

    def heartbeats (age) : Takes the average heartbeats of a year and sum a acumulative varible (av) when the year is not leap. Return av value. def yawns (age) : Takes the average yawns of a year and sum a acumulative variable (av) when the year is not leap. Return av value. def is_leap (year) : Return true if is a leap year and false if not. print ("Heartbeats: {}, yawns: {}". format (heartbeats (23), yawns (23))). Print the output of the called functions (heartbeats and yawns) for the inserted age (23).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that estimates the approximate number of times the user's heart has beat in his/her lifetime using an average heart rate of ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers