To convert decimal to binary number in python, you have to ask from user to enter a number in decimal number system to convert that number into binary number system as shown in the program given below.
Following python program ask from user to enter decimal number to convert it into binary number:
# Python Program - Convert Decimal to Binary while True: print("Enter 'x' for exit.") dec = input("Enter number in Decimal Format: ") if dec == 'x': break else: decimal = int(dec) print(decimal,"in Binary =",bin(decimal),"\n")
Here is the sample run of the above Python program to demonstrate how to convert decimal to binary number in python:
You may also like to learn or practice the same program in other popular programming languages: