SHARE
TWEET

Untitled

a guest Jul 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def to_binary(num_or_hex):
  2.     '''Function to convert an integer or hex number to a binary string'''
  3.     return format(num_or_hex, '#010b')[2:]
  4.  
  5.  
  6. if __name__ == '__main__':
  7.     print(to_binary(0x005))
  8.     print(to_binary(5))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top