Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get mid time of given time in python

# hour and minutes only
sh, sm = map(int, input().split(':')) # start time
eh, em = map(int, input().split(':')) # end time

if sh > eh or (sh == eh and sm > em):
# converting time into minutes
    mid_m = (((sh * 60) + sm) + (1440 + (eh * 60) + em)) // 2      
else:
    mid_m = (((sh * 60) + sm) + ((eh * 60) + em)) // 2
    
if mid_m >= 1440:
    mid_m = mid_m - 1440
mh = mid_m // 60
mm = mid_m - (mh * 60)

if mh < 10:
    mh = '0' + str(mh)
if mm < 10:
    mm = '0' + str(mm)
print(mh, ':', mm, sep='')
Comment

PREVIOUS NEXT
Code Example
Python :: basic kivy md 
Python :: looking up object address in python 
Python :: pandas version for python 3.9 
Python :: word search engine in python 
Python :: empty python 
Python :: affochage dun index du array list a deux dimension 
Python :: to iterate across information on same nest 
Python :: install python glob module in MacOS using pip 
Python :: python typing optional argument 
Python :: Upgrade requests-html in python 
Python :: Algorithm of Broadcasting with NumPy Arrays 
Python :: pathlib home 
Python :: display colors in python console 
Python :: tqdm start bar at 
Python :: Python NumPy asarray_chkfinite Function Example Tuple to an array 
Python :: python solve how to find only real values 
Python :: Python NumPy dsplit Function Syntax 
Python :: python pandas read parquet with progressbar 
Python :: how to fetch limited rows in pandas dataframe using sqlalchemy 
Python :: track keyboard press pynput 
Python :: NumPy unpackbits Code Unpacked array along default axis 
Python :: center pyfiglet to terminal 
Python :: gensim prepare corpus 
Python :: get token eth balance python 
Python :: python tkinter.ttk combobox down event on mouseclick 
Python :: django.db.utils.ProgrammingError: (1146 
Python :: pyqt serial plotter 
Python :: Trying to use image in Flask website only shows broken img icon 
Python :: typing effect python 
Python :: python discord next page 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =