Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. #Assign string value to the variable
  4. myText = '2019'
  5. print(type(myText))
  6.  
  7. #convert String to Integer
  8. intValue = int(myText)
  9.  
  10. #integer value
  11. print(intValue)
  12.  
  13. #type of the converted value
  14. print(type(intValue))
  15.  
  16. #convert String to Integer base 12
  17. intValue12 = int(myText, base=12)
  18.  
  19. #integer value
  20. print(intValue12)
  21.  
  22. #type of the converted value
  23. print(type(intValue12))
  24.  
  25. #convert String to Integer base 16
  26. intValue16 = int(myText, base=16)
  27.  
  28. #integer value
  29. print(intValue16)
  30.  
  31. #type of the converted value
  32. print(type(intValue16))
  33.  
  34. #convert String to Integer base 24
  35. intValue24 = int(myText, base=24)
  36.  
  37. #integer value
  38. print(intValue24)
  39.  
  40. #type of the converted value
  41. print(type(intValue24))
  42.  
  43. #convert String to Integer base 32
  44. intValue32 = int(myText, base=32)
  45.  
  46. #integer value
  47. print(intValue32)
  48.  
  49. #type of the converted value
  50. print(type(intValue32))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement