Python Program to Convert Decimal to Binary, Octal and Hexadecimal
In this article, You will learn how to write python program to Convert Decimal to Binary, Octal and Hexadecimal
In python we have inbuilt functions bin(), Oct(), hex(). We write program with the help of those functions.
#Convert decimal to binary value
dec = 522
print("The binary value is",bin(dec))
Output:
The binary value is 0b1000001010
#Convert decimal to octal value
dec = 522
print("The Octal Value is",oct(dec))
Output:
#Convert Decimal value to hexadecimal
dec = 522
print("The Hexdecimal Value is",hex(dec))
Output: