How to Convert Float Number (Fraction) to Hexadecimal in Python?

We known that in Javascript, we can use the toString(16) to convert an integer to its hexadecimal representation. That works even for float numbrs, for example, (0.5).toString(16) "0.8" (1.5).toString(16) …