Advertisement
Guest User

jazda

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. class zlaPodstawa(Exception):
  2.     def __str__(self):
  3.         return "Zła wartosc podstawy"
  4. class zlyArgument(Exception):
  5.     def __str__(self):
  6.         return "Zła wartosc argumentu"
  7. class roznePodstawy(Exception):
  8.     def __str__(self):
  9.         return "Rozne wartosci podstaw"
  10.  
  11.  
  12. class Logarytm:
  13.     def __init__(self, podstawa, argument, ):
  14.         if podstawa <= 0 or podstawa == 1:
  15.             raise zlaPodstawa()
  16.         self.podstawa = podstawa
  17.         if argument <= 0:
  18.             raise zlyArgument()
  19.         self.argument = argument
  20.  
  21.     def __add__(self, other):
  22.         if self.podstawa == other.podstawa:
  23.             return (self.podstawa, self.podstawa * other.podstawa)
  24.         else:
  25.             raise roznePodstawy()
  26.  
  27.     def __str__(self):
  28.         return "log" + self.podstawa + "(" + self.argument + ")"
  29.  
  30.     def redukuj(self):
  31.  
  32.  
  33. l = Logarytm(5, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement