Write a Python Program to Convert Decimal to Binary, Octal and Hexadecimal

Python Program to Convert Decimal to Binary, Octal and Hexadecimal

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python Program to Convert Decimal to Binary, Octal and Hexadecimal

Write a Python Program to Convert Decimal to Binary, Octal and Hexadecimal

PROGRAM: Python Program to Convert Decimal to Binary, Octal and Hexadecimal

/* Python Program to Convert Decimal to Binary, Octal and Hexadecimal */

# Python program to convert decimal into other number systems
dec = 344

print(“The decimal value of”, dec, “is:”)
print(bin(dec), “in binary.”)
print(oct(dec), “in octal.”)
print(hex(dec), “in hexadecimal.”)

OUTPUT :-

The decimal value of 344 is:
0b101011000 in binary.
0o530 in octal.
0x158 in hexadecimal.

Leave a Reply

Your email address will not be published. Required fields are marked *