Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. class MyClass:
  2.  
  3. def set(self, first, second, third):
  4. self.first = first
  5. self.second = second
  6. self.third = third
  7.  
  8. def show(self):
  9. print("first" + str(self.first))
  10. print("second" + str(self.second))
  11. print("third" + str(self.third))
  12.  
  13. def substract(self, first, second, third):
  14. return first - second - third
  15.  
  16. def sum(self, first, second, third):
  17. return first + second + third
  18.  
  19. def multiply(self, first, second, third):
  20. return first * second * third
  21.  
  22. def divide(self, first, second):
  23. try:
  24. return first / second
  25. except ZeroDivisionError:
  26. print("деление на ноль")
  27.  
  28.  
  29. a = MyClass()
  30. a.set(1,2,3)
  31.  
  32. print("sum: " + str(a.sum(5,8,8)))
  33. print("substract: " + str(a.substract(5,8,8)))
  34. print("multiply: " + str(a.multiply(5,8,8)))
  35. print("divide: " + str(a.divide(5,8)))
  36. print("divide: " + str(a.divide(5,0)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement