In this program, you will learn to convert decimal number to binary using recursive function.
o understand this example, you should have the knowledge of the following Python programming topics:
Decimal number is converted into binary by dividing the number successively by 2 and printing the remainder in reverse order.

Source Code
# Function to print binary number using recursion
def convertToBinary(n):
if n > 1:
convertToBinary(n//2)
print(n % 2,end = '')
# decimal number
dec = 34
convertToBinary(dec)
print()
Output
100010
You can change the variable dec in the above program and run it to test out for other values.
This program works only for whole numbers. It doesn’t work for real numbers having fractional values such as: 25.5, 45.64 and so on. We encourage you to create Python program that converts decimal numbers to binary for all real numbers on your own.
Related posts:
Python Set clear()
Python pass statement
Python super()
Python Closures
Deep Learning in Python - LazyProgrammer
Python Program to Find Armstrong Number in an Interval
Python bin()
Python Inheritance
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python Program to Find Sum of Natural Numbers Using Recursion
Python enumerate()
Python String isalpha()
Python sum()
Python Program to Print Colored Text to the Terminal
Python Program to Sort Words in Alphabetic Order
Python Dictionary copy()
Python String rfind()
Python Program to Count the Number of Digits Present In a Number
Python max()
Python dict()
Python type()
Binary Numbers in Java
Python timestamp to datetime and vice-versa
Python String title()
Python bytes()
Python Program to Get File Creation and Modification Date
Python map()
Python String replace()
Python Set discard()
Python compile()
Python String islower()
Python Program to Find LCM