Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import keyboard
- import time
- while True:
- i = int(input("Enter a number (0-255): "))
- time.sleep(0.2)
- keyboard.send("alt+tab") # into Turing Complete
- time.sleep(0.2)
- x = 128 # Start with the highest bit in a byte (2^7)
- while x > 0:
- if i >= x: # Check if the current bit is "on"
- print(x, end=' ') # This is the power of 2 that is "on"
- keyboard.send(str(8 - (x.bit_length() - 1))) # Keypress: 1 = 128, 2 = 64 etc
- i -= x # Subtract the value of the bit
- x = x // 2 # Move to the next lower bit
- print()
- keyboard.send("space")
- keyboard.send("alt+tab") # back to Python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement