Function Details: oct

Description


Returns the octal representation of an integer.


Extended Description


The oct() function converts an integer to a string containing its octal representation. The result is always prefixed with '0o' to indicate that it's an octal number. For negative numbers, the octal representation is prefixed with a minus sign. If the argument is not an integer, it must define an __index__() method that returns an integer.


Read More about oct from Python Documentation

Function Signature


oct(x: int) -> str

Module: builtins

Parameters



Parameter List


  • x: int

Return


Returns a string containing the octal representation of the input integer.


Return Type


str

Output

Explanation

These examples show basic usage of oct() with positive and negative integers.