Skip to content

Instantly share code, notes, and snippets.

@goyalrohit
Created September 22, 2019 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goyalrohit/cf3d3d6b57fafde918afa7c86189d5c1 to your computer and use it in GitHub Desktop.
Save goyalrohit/cf3d3d6b57fafde918afa7c86189d5c1 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# hexadecimal value
number1 = '32'
# decimal value during conversion
print(int(number1))
# considering as hexadecimal value during conversion
print(int(number1, base=16))
# another hexadecimal value that contains string value
number2 = '2e'
# considering as hexadecimal value during conversion
print(int(number2, base=16))
# raises an exception during conversion
print(int(number2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment