Menu Close

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

Python oct function is a Python built-in function that is used to convert any integer to string.


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



oct function in Python take single parameter that is integer number.

Python oct() function

Here we will take some examples to understand oct function in python.

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

#Hexadecimal to Octal
print('oct(0b101) is:', oct(0b101))

#Hexadecimal to octal
print('oct(0XA) is:', oct(0XA))


oct(10) is: 0o12
oct(0b101) is: 0o5
oct(0XA) is: 0o12


In this article, you have learned all about the Python oct function to convert any integer to octal number.
If you like this article, please share and keep visiting for further python built-in functions tutorials.

Python built-in functions

For more information:- Click Here

Previous Article
Next Article

Related Posts