Octal to decimal conversion in python by R4R Team

Octal number-

- A number which expressed in the base-8 numeral system.
- Octal number range is 0 to 7

Decimal number -
- A number which expressed in the base-10 numeral system.
- Decimal number range is 0 to 9

Conversion of Octal number to decimal number -
Example -
Octal number is 10
Its decimal equivalent is 8

octal number is 25
Its decimal equivalent is 21

program-

print("Enter Octal number")
n=int(input())
s=0
i=0
while(n>0):
t=n%10
s=s+t*(8**i)
n=int(n/10)
i=i+1

print("Decimal equivalent is - "+str(s))


output -

Enter Octal number
10
Decimal equivalent is - 8

Enter Octal number
25
Decimal equivalent is - 21


Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!