Ejemplo n.º 1
0
 def test_mul(self):
     c = calculator(3, 3)
     result = c.mul()
     self.assertEqual(result, 10)
Ejemplo n.º 2
0
     "Calculators" or programCat == "C" or programCat == "c" or \
     programCat == "Calc" or programCat == "calc" or \
     programCat == "1":
 print("Type \"calculator\" to access a basic calculator.")
 print("Type \"gpa\" to access a GPA calculator.")
 print("Type \"food\" to access a food price calculator.")
 print("Type \"sale\" to access a sale calculator.")
 print("Type \"class\" to calculate the grade for each student in a "
       "class.")
 print("Type \"max\" to access a calculator that finds the maximum "
       "of a set of numbers.")
 print("Type \"circle\" to access a circle area calculator.")
 calcCat = str(input())
 if calcCat == "calculator" or calcCat == "Calculator" or calcCat == \
         "c" or calcCat == "C" or calcCat == "1":
     calculator()
 elif calcCat == "gpa" or calcCat == "GPA" or calcCat == "Gpa" or \
         calcCat == "g" or calcCat == "G" or \
         calcCat == "2":
     gpa_calc()
 elif calcCat == "food" or calcCat == "Food" or calcCat == "3":
     food_calc()
 elif calcCat == "sale" or calcCat == "Sale" or calcCat == "4":
     sale_calculation()
 elif calcCat == "class" or calcCat == "Class" or calcCat == "5":
     student_grade()
 elif calcCat == "max" or calcCat == "Max" or calcCat == "maximum" or \
         calcCat == "Maximum" or calcCat == "6":
     max_number_function()
 elif calcCat == "circle" or calcCat == "Circle" or calcCat == "7":
     circle_area()
Ejemplo n.º 3
0
 def test_add(self):
     c = calculator(3, 5)
     result = c.add()
     self.assertEqual(result, 8)
Ejemplo n.º 4
0
 def test_add(self):
     c = calculator(2, 5)
     res = 7
     self.assertEqual(c.add(), res)
Ejemplo n.º 5
0
 def test_mul(self):
     c = calculator(3, 6)
     res = 18
     self.assertEqual(c.mul(), res)
Ejemplo n.º 6
0
 def test_divide(self):  # 对被除数为0的情况进行测试
     j = calculator(4, 0)
     self.assertEqual(j.mydivide(), 9999999999999999)
Ejemplo n.º 7
0
 def test_base(self):
     j = calculator(4, 2)  # 先定义一个self.a = 4和self.b = 2的类变量j
     self.assertEqual(j.myadd(), 6)  # 通过断言函数验证计算结果与预期结果是否一致
     self.assertEqual(j.mysubs(), 2)
     self.assertEqual(j.mymultiply(), 8)
     self.assertEqual(j.mydivide(), 2)
Ejemplo n.º 8
0
def divide():
    var_1 = request.args.get("var_1",type=float)
    var_2 = request.args.get("var_2",type=float)
    result=calculator ("Divide",var_1,var_2)
    result= str(result) 
    return "{status:200, result:"+result+"}"
Ejemplo n.º 9
0
def subtract():
    var_1 = request.args.get("var_1",type=float)
    var_2 = request.args.get("var_2",type=float)
    result=calculator ("Subtract",var_1,var_2)
    result= str(result)
    return "{status:200, result:"+result+"}"
Ejemplo n.º 10
0
from Calculator import calculator
if __name__ == '__main__':
    cont = True
    while cont == True:
        cont = calculator()