eightmoons

Untitled

Apr 3rd, 2020
205
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from math import acos
  2.  
  3.  
  4. class MathFunction:
  5.  
  6.     def __validate(self):
  7.         if not self.n > 0:
  8.             raise IOError
  9.  
  10.     def __init__(self, x, y, n):
  11.         self.x = int(x)
  12.         self.y = int(y)
  13.         self.n = int(n)
  14.         self.__validate()
  15.  
  16.     def __compute(self):
  17.         total = 1
  18.         for i in range(self.y):
  19.             total *= self.x
  20.         return total
  21.  
  22.     def __myfactorial(self):
  23.         result = 1
  24.         n = self.n
  25.         while n > 1:
  26.             result *= n
  27.             n -= 1
  28.         return result
  29.  
  30.     def __solveA(self):
  31.         return self.__compute() / self.__myfactorial()
  32.  
  33.     def __solveB(self, a): #ayusin mo nalang formula nito sa solve b
  34.         ax = 2 * a * self.x
  35.         arccos = acos(0.235 * self.n)
  36.         y3 = self.y * self.y * self.y
  37.         root = 1
  38.         return ax + (arccos / (root/y3))
  39.  
  40.     def show(self):
  41.         a_result = round(self.__solveA(), 4)
  42.         b_result = round(self.__solveB(a_result), 4)
  43.         print("Result for solveA: %s" % a_result)
  44.         print("Result for solveB: %s" % b_result)
  45.  
  46.  
  47. def inputdata():
  48.     x = input("Enter X: ")
  49.     y = input("Enter Y: ")
  50.     n = input("Enter N: ")
  51.     return MathFunction(x, y, n)
  52.  
  53.  
  54. if __name__ == "__main__":
  55.     repeat = True
  56.     while repeat:
  57.         try:
  58.             solver = inputdata()
  59.             solver.show()
  60.             inp = input("Do you want to continue? y/n >>")
  61.             repeat = inp == "y" or inp == "Y"
  62.         except IOError:
  63.             print("Please enter a positive number for n. Try again")
  64.             continue
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.

×