Home » Convert Octal to Decimal using int() in Python

# Convert Octal to Decimal using int() in Python

Learn about convert octal to a decimal using int() in Python in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.

The octal numeral system, or oct for short, is a base-8 number system that uses the digits 0 to 7. The major feature of an Octal Numbering System is that it has only 8 different counting digits ranging from 0 to 7, with each digit having a weight or value of only 8 beginning with the least important bit (LSB).

Contents

#### Program to Convert octal to decimal using int() in Python

We can use `int()` method in python to convert octal to a decimal value. Have a look at the below program for more detailed view.

Program :

``````# Python program to convert octal to decimal using int() methods

def OctalDecimal(n):
return int(n, 8)

# input from user
num = input('Enter an octal number: ')

# function call
print('The decimal value is =',OctalDecimal(num))``````

Output:

Enter an octal number: 45
The decimal value is = 37

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : Convert Octal to Decimal using Recursion in Python