oct()Easy Examples

Converts an integer to an octal string prefixed with '0o'

Basic oct() usage

Simple demonstration of the oct() built-in function.

python
print(oct(8))
print(oct(255))
print(oct(-42))

oct() is a built-in function that converts an integer to an octal string prefixed with '0o'.

oct() with different inputs

Calling oct() with various argument types.

python
# More oct() examples
print("oct() is a Python built-in function")
print(f"Type: {type(oct)}")

oct() accepts different types of arguments and produces corresponding results.

Want to try these examples interactively?

Open Easy Playground