Guest User

Untitled

a guest
Jul 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #!usr/bin/python
  2.  
  3.  
  4. def pronounce_hex(hex_val):
  5. hex_val_trunc = hex_val.lstrip('0x')
  6. hex_dict = {'1': 'Eleventy', '2': 'Twenty', '3': 'Thirty',
  7. '4': 'Fourty', '5': 'Fifty', '6': 'Sixty',
  8. '7': 'Seventy', '8': 'Eighty', '9': 'Ninety',
  9. 'A': 'Atta', 'B': 'Bibbity', 'C': 'City',
  10. 'D': 'Dickety', 'E': 'Ebbity', 'F': 'Fleventy'}
  11. pronounce = ''
  12. if len(hex_val_trunc) < 3:
  13. for i, char in enumerate(hex_val_trunc):
  14. char_str = str(char)
  15. if char == '0':
  16. continue
  17. if i < 1:
  18. pronounce += hex_dict[char_str] + '-'
  19. else:
  20. pronounce += hex_dict[char_str]
  21. return pronounce.strip()
  22. else:
  23. for i, char in enumerate(hex_val_trunc):
  24. char_str = str(char)
  25. if char == '0':
  26. continue
  27. if i < 1:
  28. pronounce += hex_dict[char_str] + '-bitey '
  29. else:
  30. pronounce += hex_dict[char_str] + ' '
  31. return pronounce.strip()
Add Comment
Please, Sign In to add comment