Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. def convert_10_to_16(n):
  2. hexlist =[]
  3. x = n // 16
  4. if x < 10:
  5. hexlist.append(x)
  6. elif (x == 10):
  7. hexlist.append('A')
  8. elif (x == 11):
  9. hexlist.append('B')
  10. elif (x == 12):
  11. hexlist.append('C')
  12. elif (x == 13):
  13. hexlist.append('D')
  14. elif (x == 14):
  15. hexlist.append('E')
  16. elif (x == 15):
  17. hexlist.append('F')
  18.  
  19. y = n % 16
  20. if y < 10:
  21. hexlist.append(y)
  22. elif (y == 10):
  23. hexlist.append('A')
  24. elif (y == 11):
  25. hexlist.append('B')
  26. elif (y == 12):
  27. hexlist.append('C')
  28. elif (y == 13):
  29. hexlist.append('D')
  30. elif (y == 14):
  31. hexlist.append('E')
  32. elif (y == 15):
  33. hexlist.append('F')
  34. return ''.join(hexlist)
  35.  
  36. def convert_10_to_16(n):
  37. hexlist =[]
  38. x = n // 16
  39. if x < 10:
  40. hexlist.append(x)
  41. elif (x == 10):
  42. hexlist.append('A')
  43. elif (x == 11):
  44. hexlist.append('B')
  45. elif (x == 12):
  46. hexlist.append('C')
  47. elif (x == 13):
  48. hexlist.append('D')
  49. elif (x == 14):
  50. hexlist.append('E')
  51. elif (x == 15):
  52. hexlist.append('F')
  53.  
  54. y = n % 16
  55. if y < 10:
  56. hexlist.append(y)
  57. elif y >= 10:
  58. z = y
  59. convert_10_to_16(z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement