Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. class Calculator:
  2.     def __init__(self, brand, model):
  3.         self._brand = brand
  4.         self._model = model
  5.  
  6.     def __str__(self):
  7.         return '{brand} {model} is ready to work!'.format(brand=self._brand, model=self._model)
  8.  
  9.     def add(self, first, second):
  10.         return first + second
  11.  
  12.     def substract(self, first, second):
  13.         return first - second
  14.  
  15.     def multiply(self, first, second):
  16.         return first * second
  17.  
  18.     def divide(self, first, second):
  19.         return first / second
  20.  
  21.     def integer_division(self, first, second):
  22.         return first // second
  23.  
  24.     def modulo(self, first, second):
  25.         return first % second
  26.  
  27. if __name__ == "__main__":
  28.     calc = Calculator('Casio', 2000)
  29.     print(calc.__str__())
  30.     print(calc.add(3, 4))
  31.     print(calc.substract(3, 4))
  32.     print(calc.multiply(3, 4))
  33.     print(calc.divide(3, 4))
  34.     print(calc.integer_division(3, 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement