Learn about Python program to convert decimal to octal using Recursion in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Python program to convert decimal to octal using Recursion
Given a decimal value, the function
DecimalOctal() converts the decimal value into an Octal value using recursion
# Python program to convert decimal to octal using recursion def DecimalOctal(num): if(num > 0): DecimalOctal((int)(num/8)) print(num%8, end='') # input num = int(input('Enter a decimal number: ')) print('Octal value is: ', end='') DecimalOctal(num)
Enter a decimal number: 35
Octal value is: 43
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Convert Decimal to Octal