def sumerino_2(): global x sum = 0 for i in range(len(x)): x[i] = x[i].replace('\n', '') sum = Math(sum) + (Math(x[i])**Math(2)) return sum
def sumerino_1(): # sum of input numbers global x sum = 0 for i in range(len(x)): x[i] = x[i].replace('\n', '') sum = Math(sum) + Math(x[i]) return sum
def factorial(self): global values, number, overwrite_flag result = Math(self.lineEdit.text()).factorial() self.lineEdit.setText(str(result)) number = [] values = [str(result)] overwrite_flag = 1 self.fit()
def evaluate(self): global values, number, overwrite_flag, log_flag, root_flag if log_flag == 1: try: result = Math(int(values)).log(int(''.join(number))) self.lineEdit.setText(str(result)) values = [str(result)] except: self.lineEdit.setText("Syntax Error") number = [] log_flag = 0 overwrite_flag = 1 elif root_flag == 1: try: result = Math(int(values)).root(int(''.join(number))) self.lineEdit.setText(str(result)) values = [str(result)] except: self.lineEdit.setText("Syntax Error") number = [] root_flag = 0 overwrite_flag = 1 else: expr = ''.join(values + number) result = Math(expr) self.lineEdit.setText(str(result)) overwrite_flag = 1 values = [str(result)] number = [] self.fit()
def log_test(): assert str(Math(2).ln()) == "0.69314718" assert str(Math(2).log(10)) == "0.30102999" assert str(Math(0.5).log(0.5)) == "1"
def init_test(): assert str(Math(5)) == "5" assert str(Math(0.1326)) == "0.1326" assert str(Math(0.9999999999)) == "0.9999999999" assert str(Math(-0.42)) == "-0.42"
def power_test(): assert str(Math(6)**Math(10)) == "60466176" assert str(Math(-3)**Math(9)) == "-19683" assert str(Math(0)**Math(80085)) == "0" assert str(Math(1.26)**Math(3)) == "2.000376"
def root_test(): assert str(Math(16).root()) == "4" assert str(Math(512).root(9)) == "2" assert str(Math(27).root(-3)) == "0.333333333333333"
def factorial_test(): assert str(Math(12).factorial()) == "479001600" assert str(Math(-10).factorial()) == "Math Error" assert str(Math(1).factorial()) == "1" assert str(Math(0).factorial()) == "1"
def simple_op_test(): assert str(Math(236) + Math(98)) == "334" assert str(Math(0.2238) + Math(1.99999)) == "2.22379" assert str(Math(236) - Math(98)) == "138" assert str(Math(0.2238) - Math(1.99999)) == "-1.77619" assert str(Math(236) * Math(98)) == "23128" assert str(Math(0.2238) * Math(1.99999)) == "0.447597762" assert str(Math(236) / Math(98)) == "2.408163265306122"
def mult_2(): global N, av m = Math(N) * (av**Math(2)) return m
def dividing_2(): global N div = Math(1.0) / (Math(N) - Math(1)) return div
def dividing_1(): # 1/N global N div = Math(1.0) / Math(N) return div