89DEVs

Python oct() function

overview of oct()

The oct() function accepts an integer number as an argument and returns the octal representation of the number. The return value is an octal string with a leading 0.

use of oct()

The oct() function can be used by passing an integer value to it. Then the octal representation of the integer value is returned. # use of oct() function octNum = oct(55) print(octNum) The integer value 55 is turned into the octal representation and then assigned to the variable octNum. Then the variable is printed. Notice that all values returned by the oct() function have always a leading 0. 0o67

syntax of oct()

The syntax of the oct() function is: oct(integer)

arguments of oct()

The oct() function accepts a single argument. It has to be an integer number, other types are not valid and will raise a TypeError exception. A TypeError exception is also raised, if none or more than one argument is provided.

return value of oct()

The oct() function returns an octal string with a leading 0, which represents the integer provided as an argument to the function.

                
        

Summary


Click to jump to section