# Python oct() Function

In this article, we are going to learn all about the Python oct() function to convert an integer to an octal string. In previous tutorials, we have seen various Python built-in functions tutorials along with examples.

## Python oct() Function Introduction

Python oct() function is a Python built-in function which means you don’t need to install it by using the pip command or no need to import from any module. oct() function in Python is used to convert any integer number to octal.

### Syntax

The syntax of oct() function in python is:-

``oct(x)``

### Parameter

oct() function in Python takes a single parameter that is an integer number. It will return TypeError if any other value will be passed other than an integer.

## Python oct() function Example

In this section, I am going to explore the oct function along with multiple examples so that you can get more clarity with the oct() function.

### Example: Converting Decimal to Octal

``````
# Deciaml to Octal
print('oct(10) is:', oct(10))``````

Output

``oct(10) is: 0o12``

### Example: Converting Hexadecimal to Octal

``````
print('oct(0XB) is:', oct(0XB))``````

Output

``oct(0XB) is: 0o13``

## Conclusion

In this article, you have learned all about the oct() function to convert any integer to an octal number. It is also capable of converting any decimal and hexadecimal value to octal.