Write a Python Program to Convert Decimal to Binary Using Recursion

Python Program to Convert Decimal to Binary Using Recursion

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Python Program to Convert Decimal to Binary Using Recursion
Python Program to Convert Decimal to Binary Using Recursion

Write a Python Program to Convert Decimal to Binary Using Recursion

PROGRAM: Python Program to Convert Decimal to Binary Using Recursion

/* Python Program to Convert Decimal to Binary Using Recursion */

# 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

Leave a Reply

Your email address will not be published. Required fields are marked *