eraz3r

Untitled

Apr 22nd, 2021
608
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. class Calculator():
  4.     def __init__(self):
  5.         pass
  6.    
  7.     @staticmethod
  8.     def addition(*args):
  9.        
  10.         return sum(args)
  11.    
  12.     @staticmethod
  13.     def substraction(a, b):
  14.         return a-b
  15.            
  16.     @staticmethod
  17.     def multiplication(*args):
  18.         product = 1
  19.         for i in args:
  20.             product = product*i
  21.         return product
  22.    
  23.     @staticmethod
  24.     def division(a ,b):
  25.         return a/b
  26.    
  27. class ScientificCalculator(Calculator):
  28.     def __init__(self):
  29.         pass
  30.    
  31.     @staticmethod
  32.     def exponential(a, b):
  33.         return a**b
  34.    
  35.     @staticmethod
  36.     def absolute(a,b):
  37.         return abs(a-b)
  38.    
  39.    
  40.    
  41. cal = ScientificCalculator()
  42.  
  43. print(cal.addition(12,34))
  44. print(cal.substraction(34,12))
  45. print(cal.multiplication(3,4))
  46. print(cal.division(8, 2))
  47. print(cal.exponential(2,2))
  48. print(cal.absolute(65,42))
  49.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×