Python oct() function

Published February 16, 2022

The oct() method is a Python built-in function for converting integer numbers to their octal counterparts. In this method, an integer is provided, and an octal string is returned.

Syntax

The syntax of the oct() method is as follows:

oct(integer)  

where Integer is the value that will be converted to the octa string


Example

In the example below, we will convert an integer into its octal value

my_integer= 100
octal_value = oct(my_integer)
print("The Octal value 100 is:",octal_value)


Output
This code will display the octal value of 100.

 

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

243 Views