fork download
  1. def calc_10_16():
  2. print("Введите число:")
  3. num=input()
  4. from_base=10
  5. to_base=16
  6. if isinstance(num, str):
  7. n = int(num, from_base)
  8. else:
  9. n = int(num)
  10.  
  11. alphabet = "0123456789ABCDEF"
  12. if n < to_base:
  13. print(alphabet[n])
  14. else:
  15. b = ''
  16. z = 0
  17. x = ''
  18. while n >= to_base:
  19. z = n // 16
  20. x = n % 16
  21. b = alphabet[x] + b
  22. n = n // 16
  23. b = alphabet[n] + b
  24. print('Число в 16-ной системе счисления: ', b)
Success #stdin #stdout 0.02s 9120KB
stdin
Standard input is empty
stdout
Standard output is empty