# Python Program to Converter a Decimal to Octal

You are Here:

## Converter a Number from Decimal to Octal

In the following example, we will convert a Decimal Number (100) to Octal Number (144).

Tips: It is recommended to use our online Decimal to Octal calculator for better understanding.

### Example

Python Compiler
import math num = 23456 arr = [0]*50 answer = [0]*50 value = 1 count = -1 j = 0 while(num > value): count += 1 value = math.pow(8, count); arr[count] = value; count -= 1 print("Octal number of 23456 (decimal) is ", end="") for i in range(count, -1, -1): answer[j] = math.floor(num / arr[i]) j += 1 num = num % arr[i] for i in range(0, count+1): print(answer[i], end="")

### Output

Octal number of 23456 (decimal) is 55640

## Converter any Given Decimal Number to Octal Number

In the following example, we will convert any given decimal number to an octal number.

### Example

Python Compiler
import math num = int(input("Enter a Decimal Number: ")); copyNum = num arr = [0]*50 answer = [0]*50 value = 1 count = -1 j = 0 while(copyNum > value): count += 1 value = math.pow(8, count); arr[count] = value; count -= 1 for i in range(count, -1, -1): answer[j] = math.floor(copyNum / arr[i]) j += 1 copyNum = copyNum % arr[i] print("Octal number of %d (decimal) is " % num, end="") for i in range(0, count+1): print(answer[i], end="")

### Output

Enter a Decimal Number: 10 Octal number of 10 (decimal) is 12

## Reminder

Hi Developers, we almost covered 90% of String functions and Interview Question on Python with examples for quick and easy learning.

We are working to cover every Single Concept in Python.