class MyMath: """ A class with math operator """ def add(self, x, y): """ Function to get the sum of x and y. Example: >>> mt=MyMath() >>> mt.add(1,2) 3 >>> mt.add(3,-2) 1 >>> mt.add(2.4,1.5) 0 """ return x + y if __name__=='__main__': import doctest doctest.testmod()
Python help
最新推荐文章于 2025-05-09 11:26:53 发布