Exemplo n.º 1
0
def calculator():
    print('\n1. addition\n\n2. sutraction\n\n3. multiplication\n\n4. division')
    choice=input('\nchoisi un\n')
    ready_to_quit(choice)
    if choice=='1':
        addition()
    if choice=='2':
        subtraction()
    if choice=='3':
        multiplication()
    if choice=='4':
        division()
Exemplo n.º 2
0
 def LaunchModule(self):
     if self.num1 < self.num2:  #swapping Number.. num1 must be greater than num2
         tmp = self.num1
         self.num1 = self.num2
         self.num2 = tmp
     if self.ButtonIndex == 0:
         obj = addition.addition(self, -1, "Addition", self.num1, self.num2,
                                 self.fontsize, self.speed)
         print 'after in addition'
     elif self.ButtonIndex == 1:
         print 'before'
         obj = subtraction.subtraction(self, -1, "Subtraction", self.num1,
                                       self.num2, self.fontsize, self.speed)
         print 'after'
     elif self.ButtonIndex == 2:
         obj = Multiplication.multiplication(self, -1, "Multiplication",
                                             self.num1, self.num2,
                                             self.fontsize, self.speed)
     elif self.ButtonIndex == 3:
         obj = FullLongDiv.LongDiv(self, -1, "Long Division", self.num1,
                                   self.num2, self.fontsize, self.speed)
     elif self.ButtonIndex == 4:
         obj = lcm.lcm(self, -1, "Least Common Multiple", self.num1,
                       self.num2, self.fontsize, self.speed)
     obj.Bind(wx.EVT_CLOSE, self.StartTimer)
Exemplo n.º 3
0
def getMenuChoice():
    #Prints menu options
    def menu():
        print(30 * "-", "Arithmetic Calculator", 30 * "-")
        print("1. Addition Calculator ")
        print("2. Subtraction Calculator ")
        print("3. Multiplication Calculator ")
        print("4. Division Calculator ")
        print("5. Exit Calculator ")
        print(83 * "-")

    loop = True
    int_choice = -1
    # While loop is True, continue iterating until False.
    while loop:
        menu()  # Displays menu
        choice = input("Enter your choice [1-5]: ")

        if choice == '1':
            int_choice = 1
            #Calls addition function on choice
            addition.addition()
            loop = True
        elif choice == '2':
            int_choice = 2
            #Calls subtraction function on choice
            subtraction.subtraction()
            loop = True
        elif choice == '3':
            int_choice = 3
            #Calls multiplication function on choice
            multiplication.multiplication()
            loop = True
        elif choice == '4':
            int_choice = 4
            #Calls devision function on choice
            division.division()
            loop = True
        elif choice == '5':
            int_choice = -1
            print("Exiting..")
            #Loop becomes False and exits the script
            loop = False
        else:
            #Any value other than 1-5 will validate as an error message to loop back to the menu
            input("Wrong menu selection. Enter any key to try again..")
    return [int_choice, choice]
Exemplo n.º 4
0
def add(): 
    input_data = request.get_json(force=True)  
    a = int(input_data.get('a')) 
    b = int(input_data.get('b')) 
    
    result = addition.addition(a,b) 
    
    return jsonify({"Result":result})
Exemplo n.º 5
0
def calculator ():

    print("Welcome to Kuba's Calculator!")
    while True:
        print("Options to do: ")
        print("Enter 'add' to use addiction(+)")
        print("Enter 'subtract' to use subtraction(-)")
        print("Enter 'multiply' to use multiplication(X)")
        print("Enter ' divide' to use division(/)")
        print("Enter 'close' to end the program :(")
        result = input("Your choice?!: ")
        if result == "add":
            num1 = input("Enter first substrate of operation: ")
            num2 = input("Enter second substrate of operation: ")
            n1t = num1.isdigit()
            n2t = num2.isdigit()
            if n1t and n2t == True:
                    product = addition(num1, num2)
                    print("it's ", product, ", and again!")
                
            else:
                print("Enter again!")
                continue
        elif result == "subtract":
            num1 = input("Enter first substrate of operation: ")
            num2 = input("Enter second substrate of operation: ")
            n2t = num2.isdigit()
            if n1t and n2t == True:
                    product = subtraction(num1, num2)
                    print("It's ", product, ", and again!")
            else:
                print("Enter again!")
                continue
        elif result == "multiplication":
            num1 = input("Enter first substrate of operation: ")
            num2 = input("Enter second substrate of operation: ")
            n2t = num2.isdigit()
            if n1t and n2t == True:
                    product = multiplication(num1, num2)
                    print("It's ", product, ", and again!")
            else:
                print("Enter again!")
                continue
        elif result == "division":
            num1 = input("Enter first substrate of operation: ")
            num2 = input("Enter second substrate of operation: ")
            n2t = num2.isdigit()
            if n1t and n2t == True:
                    product = division(product)
                    print("It's ", product, ", and again!")
            else:
                print("Enter again!")
                continue
        elif result == "close":
            break
        else:
            print("Enter again!")
            continue
    def get(self):
        args = request.args
        print(args)  # For debugging

        a = int(args['a'])
        b = int(args['b'])
        print("a is", a)
        print("b is", b)
        db_utils = addition(a, b)
        cursor = db_utils.Add()

        return cursor
Exemplo n.º 7
0
 def test_addition(self):
     a = random.randint(0, 100)
     b = random.randint(1, 100)
     c = random.randint(1, 100)
     self.assertEqual(addition.addition(a, b, c), a + b + c)
     print(a, b, c)
     print(a + b, a + c, c + b)
     print(a + b + c)
     print(a + a + a)
     print(b + b + b)
     print(c + c + c)
     print(c + c + b)
     print(c + c + a)
     print(b + b + c)
     print(b + b + a)
     print(a + a + c)
     print(a + a + b)
Exemplo n.º 8
0
 def test_basics(self):
     self.assertEqual(addition(4, 5), 9)
Exemplo n.º 9
0
from addition import addition
from uninstall import uninstall

BasePath = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BasePath)

while True:
    print("选择方式".center(20, "="))
    print("1.查找、添加\n2.添加\n3.删除")
    choice = input(">>>").strip()
    if choice.isdigit() and 0 < int(choice) <= 3:
        if int(choice) == 1:
            user_info = input("请输入语句:").strip()
            if user_info.lower().startswith("select "):
                con_info = change(user_info, "select", "from")
                select(con_info[0], con_info[1], con_info[2])
            elif user_info.lower().startswith("update "):
                con_info = change(user_info, "update", "set")
                update(con_info[1], con_info[0], con_info[2])
            else:
                print("语法错误")
        elif int(choice) == 2:
            addition("staff_table")
        else:
            uninstall("staff_table")
    elif choice == "q":
        print("Bye Bye")
        break
    else:
        print("重新选择")
Exemplo n.º 10
0
 def test_2and2and2equals6(self):
     self.assertEqual(addition(2, 2, 2), 6)
Exemplo n.º 11
0
def test_add_a_to_b():
    assert addition(2, 2) == 4
Exemplo n.º 12
0
 def add(self, a, b):
     self.result = addition(a, b)
     return self.result
Exemplo n.º 13
0
 def test_1(self):
     result = addition(3, 4)
     self.assertEqual(result, 7)
Exemplo n.º 14
0
 def test_200and200NotEquals1(self):
     self.assertNotEqual(addition(200, 200), 1)
Exemplo n.º 15
0
 def test_sendListOfarguments(self):
     self.assertEqual(addition(nums=[2, 2]), 4)
Exemplo n.º 16
0
 def test_2andMinus200EqualsMinus198(self):
     self.assertEqual(addition(2, -200), -198)
Exemplo n.º 17
0
 def test_2010and2010Equals4020(self):
     self.assertEqual(addition(2010, 2010), 4020)
Exemplo n.º 18
0
 def test_exceedMaxInt(self):
     # Max int is 2147483647, but when its larger than that is converted to negative value by subtracting 4294967296
     # So There is no limit for long integer literals apart from what can be stored in available memory.
     self.assertEqual(addition(4294967296, 4294967296), 8589934592)
Exemplo n.º 19
0
 def test_emptySumEquals0(self):
     self.assertEqual(addition(), 0)
Exemplo n.º 20
0
import addition

print(addition.addition(4, 5))
def test_addition_2():
    assert (addition(1, 1) == 2)
Exemplo n.º 22
0
 def test_3(self):
     result = addition(-4, 1)
     self.assertEqual(result, -3)
Exemplo n.º 23
0
 def test_2200and2200NotEquals4(self):
     self.assertNotEqual(addition(2200, 2200), 4)
Exemplo n.º 24
0
 def addition(self):
     ans = add.addition(self)
     self.answer_field.setText(str(ans))
def test_addition_10():
    assert (addition(6, 4) == 10)
Exemplo n.º 26
0
 def test_2and2NotEquals5(self):
     self.assertNotEqual(addition(2, 2), 5)
def test_addition_6():
    assert (addition(2, 4) == 6)
Exemplo n.º 28
0
 def test_14and12NotEquals24(self):
     self.assertNotEqual(addition(14, 14), 24)
Exemplo n.º 29
0
    @signature.setter
    def signature(self, value):
        self.builder.tkvariables["signature"].set(value)


if __name__ == '__main__':

    colorama.init()

    if len(sys.argv) > 1 and sys.argv[1] == "product":
        signer = product()
        modulo = 1014265245160156964
        bounds = 2**60, 2**64
    else:
        signer = addition()
        modulo = 4386756709
        bounds = 2**32, 2**40

    app = MyApplication(signer, bounds)
    app.modulo = modulo

    ready = False
    while not ready:
        try:
            app.makeKeys()
        except ValueError as e:
            print(colored("Exception while trying to generate the keys",
                          "red"))
            print(colored(str(e), "red"))
        else:
Exemplo n.º 30
0
 def test_raisesInvalidType(self):
     with self.assertRaises(TypeError):
         addition("a", "b")