Full name
oct
Library
Built-in
Syntax
oct(n)
Description
The oct function converts an integer to its octal representation in text and lowercase format, preceded by the characters "0o" (a zero followed by the letter o).
Parameters
- n: Integer to convert to octal format.
Examples
Different integers, both positive and negative, are converted to their octal representation:
print(oct(-255))
print(oct(-1))
print(oct(0))
print(oct(1))
print(oct(255))
-0o377
-0o1
0o0
0o1
0o377
-0o1
0o0
0o1
0o377