How to print decimal, octal, hexadecimal and binary in a single line of a given integer in Python

1 Answer

0 votes
i = 35

o = str(oct(i))[2:]

h = str(hex(i))[2:]
h = h.upper()

b = str(bin(i))[2:]

d = str(i)
print("Decimal Octal Hexadecimal, Binary")
print(d,'    ',o,'  ',h,'         ',b)



 
'''
run:

Decimal Octal Hexadecimal, Binary
35      43    23           100011
 
'''

 



answered Sep 14, 2021 by avibootz

Related questions

...