Пример #1
0
def method():
    while True:
        print("Welcome to the simple calculator in python")
        op = input("Enter the operator: ")
        thislist = []
        a = True

        while a == True:
            n1 = input("enter the number: ")
            print("To calculate type '=': ")
            if n1 == "=":
                a = False
            else:
                n1 = float(n1)
                thislist.append(n1)

        if op == "+":
            answer = addition.add(thislist)
            print("result: " + str(answer))
            print(thislist)
        elif op == "-":
            answer = subtraction.sub(thislist)
            print("result: " + str(answer))
        elif op == "*":
            answer = multiplication.mul(thislist)
            print("result: " + str(answer))
        elif op == "/":
            answer = division.div(thislist)
            print("result: " + str(answer))
        else:
            print("Invalid operator")

        print(" ")
Пример #2
0
d = int(
    input(
        'Enter a value from the choice below:\nPress1,for addition\nPress2 for subraction\npress3 for multiplication\npress4 for division\nYour choice:'
    ))
if d == 1:
    import addition
    a = int(input('Enter a value for 1st number:'))
    b = int(input('Enter a value for 2nd number:'))
    c = a + b
    addition.add(c)
if d == 2:
    import subraction
    a = int(input('Enter a value for 1st number:'))
    b = int(input('Enter a value for 2nd number:'))
    e = a - b
    subraction.sub(e)

if d == 3:
    import multiplication
    a = int(input('Enter a value for 1st number:'))
    b = int(input('Enter a value for 2nd number:'))
    f = a * b
    multiplication.mul(f)
if d == 4:
    import divition
    a = int(input('Enter a value for 1st number:'))
    b = int(input('Enter a value for 2nd number:'))
    g = a / b
    divition.div(g)
else:
    print "Sometin went wrong"
 def test_simple_mul(self):
     """
     Tests the one digit multiplication table
     """
     self.assertEquals(mul(5, 6), 30)
 def test_even_digits_mul(self):
     """
     Tests the simpler case where the number of digits is even
     """
     self.assertEquals(mul(49, 57), 2793)
     self.assertEquals(mul(5678, 1234), 7006652)
Пример #5
0
 def test_mul(self):
     self.assertEqual(mul(7, 3), 7 * 3)
Пример #6
0
 def test_simple_mul(self):
     """
     Tests the one digit multiplication table
     """
     self.assertEquals(mul(5, 6), 30)
Пример #7
0
 def test_even_digits_mul(self):
     """
     Tests the simpler case where the number of digits is even
     """
     self.assertEquals(mul(49, 57), 2793)
     self.assertEquals(mul(5678, 1234), 7006652)