Python program to convert Decimal number to a Binary number

In this program, we will see a way to convert decimal number to a binary number using Python programming language.


We are employing a built-in function bin() to convert the decimal number.

Follow the code given below:

# decimal number
number = int(input("Enter any decimal number: "))

# print equivalent binary number

print("Equivalent Binary Number: ", bin(number))

------------------------
Output:
Enter any decimal number: 42
Equivalent binary number: 0b101010

That's it!
Facing any issues comment down we are free to help you.
liked the content don't forget to share with your fellow mates.

No comments:

Post a Comment