Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

decimal hour to hour minute python

>>> def frac(n):
...     i = int(n)
...     f = round((n - int(n)), 4)
...     return (i, f)
...
>>> frac(53.45)
(53, 0.45) # A tuple 

>>> def frmt(hour): # You can rewrite it with 'while' if you wish
...     hours, _min = frac(hour)
...     minutes, _sec = frac(_min*60)
...     seconds, _msec = frac(_sec*60)
...     return "%s:%s:%s"%(hours, minutes, seconds)
...
>>> frmt(72.345)
'72:20:42'
>>> l = [72.345, 72.629, 71.327]
>>> map(frmt, l)
['72:20:42', '72:37:44', '71:19:37']
Comment

PREVIOUS NEXT
Code Example
Python :: python 3 docs 
Python :: how to use histogram in python 
Python :: menor valor lista python 
Python :: Python Permutation without built-in function [itertools] for Lists 
Python :: plot the distribution of value_counts() python 
Python :: sum of list of numbers 
Python :: python logging levels 
Python :: count unique values in python 
Python :: compare string python 
Python :: How to build a Least Recently Used (LRU) cache, in Python? 
Python :: django pass list of fields to values 
Python :: python serial COM3 
Python :: permutation and combination in python 
Python :: python second element of every tuple in list 
Python :: convert file dta in csv 
Python :: quotation marks n string 
Python :: python toupper 
Python :: bad request 400 heroku app 
Python :: if a specific column name is present drop tyhe column 
Python :: How to convert datetime in python 
Python :: convert plt.show to image to show opencv 
Python :: convert decimal to float in python 
Python :: python get dir from path 
Python :: django filter values with OR operator 
Python :: jacobi iteration method python 
Python :: how to check whether input is string or not 
Python :: how to find out the max and min date on the basis of property id in pandas 
Python :: how to add some thing in python list 
Python :: request.args.get check if defined 
Python :: How to Join list element into a string in python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =