Computer Science, asked by NandyJ8024, 11 months ago

How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?

Answers

Answered by Smitvan
0

Python Program to Convert Decimal to Binary, Octal and Hexadecimal. Decimal System: The most widely used number system is decimal system. This system is base 10 number system. In this system, ten numbers (0-9) are used to represent a number.

Answered by HariniNivetha
1

A Python program to convert Decimal to Binary, Octal and Hexadecimal number systems.

_________________________________________

# Python program to convert decimal number into binary, octal and hexadecimal number system

# We can change this value to check for different numbers

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.

A number with the prefix ‘0b’ is considered binary, ‘0o’ is considered octal and ‘0x’ as hexadecimal. For example:

60 = 0b11100 = 0o74 = 0x3c

Similar questions