How to Use oct() Function in PythonPython Basics


The oct() function converts an integer into an octal string.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print("oct(10):  ", oct(10))
print("oct(0):  ", oct(0))
print("oct(11):  ", oct(11))
print("oct(9):  ", oct(9))

Output:

oct(10):   0o12
oct(0):   0o0
oct(11):   0o13
oct(9):   0o11

Syntax

oct(x)

Parameters

The function doesn’t take any parameters.

Return Value

The function doesn’t return any values.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us