Stuck again, still, im learning from my large list of mistakes, haha
so this time im trying to convert a decimal to hexadecimal, i tried using hex(number)
but its not suitable for the situation as this returns a string. and i dont know how or if i can convert a string to hexadecimal. I tried to use string formatting as follows;
return "%x" % num
the objective is as follows
Format string output by using the '%' operator
>>> 1.0/3 0.33333333333333331 >>> print "%.2f" % (1.0/3) # Convert to floating point with 2 decimal place 0.33 >>> name = "John" >>> age = 27 >>> print "My name is %s. I am %d years old." % (name, age) My name is John. I am 27 years old. >>> dec2hex(11) '0x0b'
dec2hex(34) should result with the following output;
and dec2hex(10) should result with;
i dont know much about hexadecimal, i should mention.
please advise my situation.
Edited 3 Years Ago by Dani: Formatting fixed