Pour un débutant, cela ne me semble pas aussi simpliste que certains le disent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #! python3
# coding: utf-8
from math import trunc
# dict mapping dec -> hexa
D2H = dict(zip(range(16), "0123456789abcdef"))
def to_hex(n: int) -> str:
lst = []
while True:
if n >= 16:
quotient = trunc(n / 16)
reste = n % 16
lst.append(str(D2H[reste])) |
...