Skip to content

Instantly share code, notes, and snippets.

@ixxra
Last active April 4, 2023 16:48
Show Gist options
  • Select an option

  • Save ixxra/8651122 to your computer and use it in GitHub Desktop.

Select an option

Save ixxra/8651122 to your computer and use it in GitHub Desktop.
Simple binary/hexadecimal clock written in python for my "introduction to numerical analysis class".
'''
Simple binary/hexadecimal clock written in python.
This programm is an example for my "introduction to numerical analysis class" at Universidad Autonoma de Yucatan.
Feel free to copy/modify at your convenience.
'''
import time
def decimal_time():
'''
Simple function to return a triad
(hour, minute, seconds)
in decimal base.
'''
t = time.strftime('%H %M %S').split()
return tuple(map(int, t))
while True:
t = decimal_time()
print '----------------------------'
print ''
print 'Decimal time:'
print '%s : %s : %s' % t
print ''
print 'Binary time:'
print '%s : %s : %s' % tuple(map(bin, t))
print ''
print 'Hexadecimal time:'
print '%s : %s : %s' % tuple(map(hex, t))
print ''
time.sleep(1)
@CreepercraftYT
Copy link
Copy Markdown

CreepercraftYT commented Apr 4, 2023

`
'''
Simple binary/hexadecimal clock written in python.

This programm is an example for my "introduction to numerical analysis class" at Universidad Autonoma de Yucatan.

Feel free to copy/modify at your convenience.
'''
import time

def decimal_time():
'''
Simple function to return a triad

(hour, minute, seconds) 

in decimal base.
'''
t = time.strftime('%H %M %S').split()
return tuple(map(int, t))

while True:
t = decimal_time()
H=int(t[0])
M=int(t[1])
S=int(t[2])
print ('----------------------------')
print('')

print( 'Decimal time:')
print( '%s : %s : %s' % t)
print( '')
print( 'Binary time:')
print(bin(H),':',bin(M),':', bin(S))
print( '')
print( 'Hexadecimal time:')
print(hex(H),':',hex(M),':',hex(S))
print( '')

time.sleep(1)

`

I fixed it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment