Octal number-
- A number which expressed in the base-8 numeral system.
- Octal number range is 0 to 7
Deciaml number -
- A number which expressed in the base-10 numeral system.
- Decimal number range is 0 to 9
Conversion of Decimal to octal number
Example-
Decimal number - 10
Its octal equivalent is 1010
Decimal number - 11
Its octal equivalent is 1011
Program -
print("Enter decimal number")
n=int(input())
octal=""
l=[]
#break decimal number into octal bits
while(n>0):
t=n%8
l.append(t)
n=int(n/8)
i=len(l)-1
#traverse list in reverse order
while(i>=0):
octal=octal+str(l[i])
i=i-1
print("Its octal equivalent is - "+octal)
Enter decimal number
10
Its octal equivalent is - 12
Enter decimal number
45
Its octal equivalent is - 55