kiril_1914

OOP_@staticmethod_task: Calculator

Jan 3rd, 2023
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. from functools import reduce
  2.  
  3. class Calculator:
  4.  
  5.     @staticmethod
  6.     def add(*args):
  7.         return sum(args)
  8.  
  9.     @staticmethod
  10.     def multiply(*args):
  11.         result = reduce(lambda x, y: x * y, args)
  12.         return result
  13.  
  14.     @staticmethod
  15.     def divide(*args):
  16.         result = reduce(lambda x, y: x / y, args)
  17.         return result
  18.  
  19.     @staticmethod
  20.     def subtract(*args):
  21.         result = reduce(lambda x, y: x - y, args)
  22.         return result
  23.  
Advertisement
Add Comment
Please, Sign In to add comment