>>> # testing Question 12 time format (8,0) \"8 o\'clock >time_format(8,2) \"8 o
ID: 3873464 • Letter: #
Question
>>> # testing Question 12 time format (8,0) "8 o'clock >time_format(8,2) "8 o'clock "9 o'clock "10 minutes past 8 o'clock" half past 8 "10 minutes to 9 o'clock" time format(8,59) time format (8,8) time format(8,32) time format(8,48) time_format(17,42) "20 minutes to 18 o'clock" time format (23,13) "15 minutes past 23 o'clock time format (23,42) "20 minutes to 0 o'clock" time format(0,29) "half past o'clock" "12 o'clock" "0 o'clock "0 o'clock "11 o'clock" time_format (11,59) time format (23,58) time_format (0,1) time format(11,1)Explanation / Answer
'''
here is the code
please add indentation if there is not
'''
def time_format(h,m):
if h==23:
g = 0
else:
g = h+1
g = str(g)
h = str(h)
fix = " o'clock"
mm = "minutes past "
kk = "minutes to "
hh = "half past "
if m>=0 and m<=4:
return h+fix
elif m>=5 and m<=9:
return "10 "+mm + h+fix
elif m>=10 and m<=14:
return "15 "+mm+h+fix
elif m>=15 and m<=19:
return "20 "+mm+h+fix
elif m>=20 and m<=24:
return "25 "+mm+h+fix
elif m>=25 and m<=29:
return hh+h+fix
elif m>=30 and m<=34:
return hh+h+fix
elif m>=35 and m<=39:
return "20 "+kk+g+fix
elif m>=40 and m<=44:
return "15 "+kk+g+fix
elif m>=45 and m<=49:
return "10 "+kk+g+fix
elif m>=50 and m<=54:
return "5 "+kk+g+fix
elif m>=55:
return g+fix
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.