def get_probability(s_p, p, t, n): wts = dict() for i in range(0, n): wts[i] = 0 for elem in s_p: weight = calc.wt(elem[0]) wts[weight] += 1 res = 0 for key, value in wts.items(): res += (calc.pow(p, key) * calc.pow(1 - p, n - key)) * value return 1 - res
import calc as op while (True): print "MENU \n1.Add\n2.Subtract\n3.Divivde\n4.Multiply\n5.Remainder\n6.Power\n7.Exit\n\nEnter your choice for calculation :", ch = input() if ch == 7: exit(0) a = input("Enter first input :") b = input("Enter second input :") if ch == 1: print "The sum is :", op.add2(a, b) elif ch == 2: print "The difference is :", op.sub2(a, b) elif ch == 3: print "The division result is :", op.div2(a, b) elif ch == 4: print "The product is :", op.mul2(a, b) elif ch == 5: print "The remainder is :", op.rem1(a, b) elif ch == 6: print "The result of a^b is :", op.pow(a, b) else: print "Invalid choice!!" print "\n\n"
def test_pow(self): self.assertEqual(calc.pow(1, 2), 3)
from calc import pow # print(calc.sum(1, 2, 3, 4, 5)) print(pow(2, 5))
def test_pow ( self ): self.assertEqual(calc.pow( 3 , 3 ), 27 )
def test_sub(self): """Тест на возведение в степень""" print("id: " + self.id()) self.assertEqual(calc.pow(3, 3), 27)
Ans=op.add2(float(n1),float(n2)) print "\n",n1+ch[opf]+n2,"=",Ans elif ch[opf]=='-' : Ans=op.sub2(float(n1),float(n2)) print "\n",n1+ch[opf]+n2,"=",Ans elif ch[opf]=='/' : Ans=op.div2(float(n1),float(n2)) print "\n",n1+ch[opf]+n2,"=",Ans elif ch[opf]=='*' : Ans=op.mul2(float(n1),float(n2)) print "\n",n1+ch[opf]+n2,"=",Ans elif ch[opf]=='%' : Ans=op.rem1(float(n1),float(n2)) print "\n",n1+ch[opf]+n2,"=",Ans elif ch[opf]=='^' : Ans=op.pow(float(n1),float(n2)) print "\n",n1+ch[opf]+n2,"=",Ans elif trigop == 'Sin' or trigop == 'sin': Ans=op.sinc(float(n1),float(n2)) print "\n",n1+trigop+n2,"=",Ans elif trigop == 'Cos' or trigop == 'cos': Ans=op.cosc(float(n1),float(n2)) print "\n",n1+trigop+n2,"=",Ans elif trigop == 'Tan' or trigop == 'tan': Ans=op.tanc(float(n1),float(n2)) print "\n",n1+trigop+n2,"=",Ans elif trigop == 'Cosec' or trigop == 'cosec': Ans=op.cosecc(float(n1),float(n2)) print "\n",n1+trigop+n2,"=",Ans elif trigop == 'Sec' or trigop == 'sec': Ans=op.secc(float(n1),float(n2))
def test_pow(self): self.assertEqual(calc.pow(2,3),8) self.assertEqual(calc.pow(2.2,3),2.2**3) self.assertEqual(calc.pow(2,-3),2**-3) self.assertEqual(calc.pow(2,"d"),"DTNS")
def test_pow(self): assert calc.pow(2, 3) == 8
def test_pow(self): self.assertEqual(calc.pow(2, 0), 1) self.assertEqual(calc.pow(2, 1), 2) self.assertEqual(calc.pow(2, -1), 0.5) self.assertEqual(calc.pow(-2, -1), -0.5)
def test_pow(self): result = calc.pow(10,5) self.assertEquals(result,100000)
def test_pow(self): self.assertEqual(calc.pow(2, 6), 64)