object .__ floor__ in Python

Allows you to determine the result of the math.floor () function.

object .__ floor __ (self)

self - A reference to the instance. 

If this method is defined in a custom class, then it will be called when referring to math .floor () .

  from math import floor 

class MyClass:

def __init__ (self, val):
self.val = val

def __floor __ (self):
return self.val - 1

my_var = MyClass (6)
floor (my_var) # 5

Get Solution for free from DataCamp guru