Python hex()

Configurare noua (How To)

Situatie

The hex() function converts an integer number to the corresponding hexadecimal string.

Solutie

Pasi de urmat

number = 435
print(number, ‘in hex =’, hex(number))

number = 0
print(number, ‘in hex =’, hex(number))

number = -34
print(number, ‘in hex =’, hex(number))

returnType = type(hex(number))
print(‘Return type from hex() is’, returnType)

Output:

435 in hex = 0x1b3
0 in hex = 0x0
-34 in hex = -0x22
Return type from hex() is <class ‘str’>

Tip solutie

Permanent

Voteaza

(4 din 6 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?