Answer:
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)))
Step-by-step 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).