Python oct() Function
Converts an integer to octal, a base 8 number.
||Required. The value to convert|
squawk = 7421 print(oct(squawk))
If the object is not an
int, is has to define the
__index__() function and
return an integer.
class Transponder(): squawk = 7421 def __index__(self): return self.squawk print(oct(Transponder()))Output:
Who uses Octal?
Octal is often used in aviation — transponders in aircraft transmit a code, expressed as a four-octal-digit number, when interrogated by ground radar. This code is used to distinguish different aircraft on the radar screen.