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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started