Skip to content

Instantly share code, notes, and snippets.

@vubon
Last active January 1, 2017 17:25
Show Gist options
  • Save vubon/5ad6b76a66d1d8afa3c4e40c5422fb1c to your computer and use it in GitHub Desktop.
Save vubon/5ad6b76a66d1d8afa3c4e40c5422fb1c to your computer and use it in GitHub Desktop.
Converting Decimal Number <=> Binary Number and Decimal Number <=> Hexadecimal Number
num = int(input("Enter your number: "))
result = bin(num)[2:]
hexnum = hex(num)[2:]
print("Your binary number: ", result)
print("Your Hexadecimal number: ", hexnum)
print("........................................")
intResult= int(result, 2)
hexResult= int(hexnum, 16)
print("Your integer number: ",intResult)
print("Your integer number: ",hexResult)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment