Created
September 9, 2018 18:02
-
-
Save jb0hn/e29e4db5edbeecf5502819b5c9b5ebd9 to your computer and use it in GitHub Desktop.
Binary, decimal, hex counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# import modules | |
import sys | |
import time | |
# clear terminal | |
def cls(): | |
print('\n' * 100) | |
def main(): | |
cls() | |
for i in range(1000000): | |
sys.stdout.write("{:020b}".format(i)) # binary | |
sys.stdout.write(" ") | |
sys.stdout.write("{:07d}".format(i)) # decimal | |
sys.stdout.write(" ") | |
sys.stdout.write("{:07x}\r".format(i)) # hex | |
sys.stdout.flush() # reset cursor | |
time.sleep(0.05) # wait 0.05 s between iterations | |
# exec | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment