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 Program to Delete an Element From a Dictionary
Python Program to Find the Largest Among Three Numbers
Python Program to Find the Square Root
Python List extend()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Find Armstrong Number in an Interval
Python id()
Java Program to Delete a Particular Node in a Tree Without Using Recursion
Python Set symmetric_difference_update()
Python any()
Python bytearray()
Python Closures
Python Program to Check If Two Strings are Anagram
Python String rindex()
Python Program to Get the Last Element of the List
Python String strip()
Python Dictionary update()
Python String translate()
Python String zfill()
Deep Learning with Python - Francois Chollet
Python String isspace()
Python Data Structures and Algorithms - Benjamin Baka
Python Function Arguments
Python Operator Overloading
Python open()
Python Object Oriented Programming
Python Program to Transpose a Matrix
Python time Module
Python delattr()
Debug a JavaMail Program
Python Set pop()
Python Dictionary fromkeys()