In this program, we have defined a function for conversion to be named DecimalToBinary ().

This function takes the decimal number as the input parameter and converts it to the equivalent binary number.

Decimal to Binary conversion:-

def decimalToBinary(number): if number > 1: decimalToBinary(number // 2) print(number % 2, end='') number = int(input("Enter the decimal number you want to convert in binary: ")) decimalToBinary(number)

Output:-

we can also convert decimal number to binary number through in-built bin() function. # Take Input decimal number num = int(input("Enter decimal number you want to convert in binary: ")) # print equivalent binary number print("Equivalent Binary Number: ", bin(num))

Output:-