#Chuong trinh Python Calculator #Su dung cac Module, Function #haind #Python import cal vonglap = 1 choice = 0 while vonglap == 1: choice = cal.menu() if choice == 1: cal.add() elif choice == 2: cal.sub() elif choice == 3: cal.mul() elif choice == 4: cal.div() elif choice == 5: vonglap = 0 print "Cam on ban da su dung chuong trinh"
res = cal.add(num1, num2) print("The result of add of two numbers", res) elif (choice1 == 2): num1 = int(input("enter the number1\n")) num2 = int(input("enter the number2\n")) res = cal.sub(num1, num2) print("The result of sub of two numbers", res) elif (choice1 == 3): num1 = int(input("enter the number1\n")) num2 = int(input("enter the number2\n")) res = cal.mul(num1, num2) print("The result of mul of two numbers", res) elif (choice1 == 4): num1 = int(input("enter the number1\n")) num2 = int(input("enter the number2\n")) res = cal.div(num1, num2) print("The result of div of two numbers", res) elif (choice1 == 5): break else: print("enter the correct choice") except NameError, details: print("invalid integer", details) except IOError, details: print("invalid integer", details) except ValueError, details: print("enter valid input", details) except NameError, details: print("invalid integer", details) except IOError, details: print("invalid integer", details)
import cal vonglap = 1 choice = 0 while vonglap == 1: choice = cal.menu() if choice == 1: cal.add() elif choice == 2: cal.sub() elif choice == 3: cal.mul() elif choice == 4: cal.div() elif choice == 5: vonglap = 0
# import cal from cal import add, sub, mul, div, sine while (True): inp = input() if (inp == "stop"): break n = int(input()) m = int(input()) d = { "add": add(n, m), "sub": sub(n, m), "mul": mul(n, m), "div": div(n, m), } print(d[inp]) # s = add(n, m) # sub = sub(8, 4) # mul = mul(4, 8) # div = div(8, 4) # print(s, sub, mul, div) # print(sine(90))
def test_div(self): self.assertEqual(cal.div(10,2), 3)
def test_div(self): self.assertEqual(cal.div(8,2), 4)
import cal as c a=9 b=7 print(c.add(a,b)) print(c.sub(a,b)) print(c.mul(a,b)) print(c.div(a,b))
print("hello world !") def func(): print("hello") func() import cal print ( cal.div(10,5) ) print ( cal.CONSTANT ) a = cal.A() print(type(a))