Home > other >  Which Python is a great god for help
Which Python is a great god for help

Time:09-17

Please adopt the way of function. Write a decimal number converted to hexadecimal program, namely, the main program: prompt to convert decimal number, and will enter a decimal digital handed the conversion function is invoked, in the main program output conversion results; Decimal conversion function over the caller, and returns the conversion result,

CodePudding user response:

Directly with hex () can change the decimal into hexadecimal

CodePudding user response:

The
reference 1/f, kohane Jary response:
directly with hex () can change the decimal into hexadecimal

Can't use hex ()

CodePudding user response:

 def to_hex (N) : 
If N<16:
Return the STR (N)
The else:
Return to_hex (N//16) + (STR (16) N % if N % 16 & lt; 10 the else CRH (N % 16-10 + 65))
  • Related