Question: 5. Write a function calculate_hours_or_minutes that takes three arguments hours, minutes, and time_format. If the value of time_format is minutes, the function should do the
5. Write a function calculate_hours_or_minutes that takes three arguments hours, minutes, and time_format. If the value of time_format is "minutes", the function should do the same thing as calculate_minutes above. Otherwise if the value of time_format is "hours", it should return fractional number of hours that the sum of hours and minutes represents. Eg. calculate_hours_or_minutes(3, 15, "hours") should return 3.25.
def calculate_hours_or_minutes(hours, minutes, time_format):
# write your code here
print(calculate_hours_or_minutes(3, 15, "minutes"))
print(calculate_hours_or_minutes(3, 15, "hours"))
5. Write a function calculate_hours_or_minutes that takes three arguments hours, minutes, and time_format. If the value of time_format is "minutes", the function should do the same thing as calculate_minutes above. Otherwise if the value of time_format is "hours", it should return fractional number of hours that the sum of hours and minutes represents. Eg. calculate_hours_or_minutes(3, 15, "hours") should return 3.25.
def calculate_hours_or_minutes(hours, minutes, time_format):
# write your code here
print(calculate_hours_or_minutes(3, 15, "minutes"))
print(calculate_hours_or_minutes(3, 15, "hours"))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
