Skip to content

Instantly share code, notes, and snippets.

@goyalrohit
Last active September 22, 2019 03:10
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/79afd4b923c6a6c4536906b637f891a4 to your computer and use it in GitHub Desktop.
Save goyalrohit/79afd4b923c6a6c4536906b637f891a4 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#Assign string value to the variable
myText = '2019'
print(type(myText))
#convert String to Integer
intValue = int(myText)
#integer value
print(intValue)
#type of the converted value
print(type(intValue))
#convert String to Integer base 12
intValue12 = int(myText, base=12)
#integer value
print(intValue12)
#type of the converted value
print(type(intValue12))
#convert String to Integer base 16
intValue16 = int(myText, base=16)
#integer value
print(intValue16)
#type of the converted value
print(type(intValue16))
#convert String to Integer base 24
intValue24 = int(myText, base=24)
#integer value
print(intValue24)
#type of the converted value
print(type(intValue24))
#convert String to Integer base 32
intValue32 = int(myText, base=32)
#integer value
print(intValue32)
#type of the converted value
print(type(intValue32))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment