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:
Deep Learning with Python - Francois Cholletf
Python Program to Find the Square Root
Python Machine Learning Eqution Reference - Sebastian Raschka
Python String format_map()
Python Program to Find the Sum of Natural Numbers
Python String rindex()
Python Program to Convert Kilometers to Miles
Python callable()
Python Operators
Python Program to Sort Words in Alphabetic Order
Python Program to Get File Creation and Modification Date
Python Dictionary setdefault()
Python Program to Access Index of a List Using for Loop
Python Program to Find the Factorial of a Number
Python Program to Get the Class Name of an Instance
Python List sort()
Intelligent Projects Using Python - Santanu Pattanayak
Python strftime()
Python if...else Statement
Python filter()
Python List reverse()
Python Errors and Built-in Exceptions
Python String expandtabs()
Python float()
Python Program to Check if a Number is Positive, Negative or 0
Python Program to Iterate Through Two Lists in Parallel
Python Program to Find Numbers Divisible by Another Number
Python max()
Python Set discard()
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Program to Multiply Two Matrices
Python Dictionary items()