The program asks the user to input the decimal number, In Python we have built in functions to convert decimal to binary, just use bin() function to convert any number. So we don't have to worry about the mathematics behind how to convert decimal numbers to binary.
#Getting input from the user
dec = int(input("Enter the decimal value: "))
print("The decimal value of",dec,"is:",bin(dec)[2:],"in binary.")
Enter the decimal value: 14 The decimal value of 14 is: 1110 in binary.
Nothing yet..be the first to share wisdom.