oct()
function is used to find the takes an integer number and returns its octal representation. If the given number is an int, it must implement __index__() method to return an integer in Python for the given input.
oct()
function is a part of Python Built-in Functions.
Syntax of oct()
Function
The syntax of
oct()
function in Python is:
oct(x)
Parameters of oct()
Function in Python
x
– Where x
is any valid . This parameter is required.
Compatibility
oct()
function is available and compatible with both Python 2.x
and 3.x
.
Return Value of oct()
Function in Python
oct()
function returns takes an integer number and returns its octal representation. If the given number is an int, it must implement __index__() method to return an integer for the given input.
Python oct()
Function Example 1
Example CODE
Output:
Python oct()
Function Example 2
Example CODE
Output: