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
最新推荐文章于 2023-11-11 23:33:29 发布