Answers for "function to convert minutes to hours and minutes python"

3

convert seconds to hours python

method = a
import datetime
str(datetime.timedelta(seconds=666))
'0:11:06'

method = b
def convert(seconds):
    seconds = seconds % (24 * 3600)
    hour = seconds // 3600
    seconds %= 3600
    minutes = seconds // 60
    seconds %= 60      
    return "%d:%02d:%02d" % (hour, minutes, seconds)
Posted by: Guest on May-09-2021
0

function to convert minutes to hours and minutes python

def format_time(minutes):
    hours_total = minutes // 60
    # Get additional minutes with modulus
    minutes_total = minutes % 60
    # Create time as a string
    time_string = "{} hours {} minutes".format(hours_total, minutes_total)
    return time_string
Posted by: Guest on April-21-2022

Code answers related to "function to convert minutes to hours and minutes python"

Python Answers by Framework

Browse Popular Code Answers by Language