Beispiel #1
0
    def calculate_result(self, new_input: str):

        if self.dialog.lineEditResult.text() == '':
            self.dialog.lineEditResult.setText(new_input)

        else:
            cache_number = int(self.dialog.lineEditResult.text())
            target_operator = self.dialog.labelOperator.text()
            try:
                new_number = int(new_input)

                if target_operator == '+':
                    result = operations.addition(cache_number, new_number)
                elif target_operator == '-':
                    result = operations.minus(cache_number, new_number)
                elif target_operator == '*':
                    result = operations.multiplication(cache_number,
                                                       new_number)
                elif target_operator == '/':
                    if new_number == 0:
                        self.throw_error()
                    else:
                        result = operations.division(cache_number, new_number)

                self.dialog.lineEditInput.setText('')
                self.dialog.lineEditResult.setText(str(result))
            except:
                self.throw_error()
Beispiel #2
0
    Exponential of number --> 13     Sine (sinx)    --> 14
    Exit                  --> 17     Cosine(cosx)   --> 15 
                                     Tangent(tanx)  --> 16
   
    """)

    operator = int(input("Please Enter Your Choice :--> "))

    if operator == 1:
        result = addition(num1, num2)
    elif operator == 2:
        result = subtraction(num1, num2)
    elif operator == 3:
        result = multiplication(num1, num2)
    elif operator == 4:
        result = division(num1, num2)
    elif operator == 5:
        result = integer_division(num1, num2)
    elif operator == 6:
        result = power(num1, num2)
    elif operator == 7:
        result = modulo(num1, num2)
    elif operator == 8:
        result = log(num1, num2)
    elif operator == 9:
        result = sigmoid(num1 + num2)
    elif operator == 10:
        result = rand_between(num1, num2)
    elif operator == 11:
        result = hcf(num1, num2)
    elif operator == 12:
Beispiel #3
0
import operations

print(operations.division(20,1))

print('Uvod')
Beispiel #4
0
import operations
import math
import cmath

c = operations.addition(5, 6)
d = operations.division(20, 20)

print(c, d)

e = math.asin(1)
print(e)

# JSON - JS OBJECT NOTATION
Beispiel #5
0
 print("3. Division")
 print("4. Multiplication")
 print("5. Power")
 print("6. Algorithms")
 print("7. Quit")
 print("{:_^20}").format("")
 #ask user what they want to do
 user_choice = user_input.check_int()
 print("{:_^20}").format("")
 #call function based on user choice
 if (user_choice == 1):
     operations.addition()
 elif (user_choice == 2):
     operations.subtraction()
 elif (user_choice == 3):
     operations.division()
 elif (user_choice == 4):
     operations.multiplication()
 elif (user_choice == 5):
     operations.power()
 elif (user_choice == 6):
     #let user choose what algorithm they want to run
     print("You selected algorithms.")
     print("1. Fibanacci")
     print("2. Pythagoras")
     user_choice2 = user_input.check_int()
     while (True):
         if (user_choice2 == 1):
             y = int(raw_input("How many times would you like to loop?\n"))
             print("{:_^20}").format("")
             while (True):
Beispiel #6
0
 def test_division(self):
     self.assertEqual(operations.division(50, 2), 25)
Beispiel #7
0
def add_operation(a, b):
    add = op.addTwoNumbers(a, b)
    mult = op.multiplication(a, b)
    div = op.division(a, b)
    return {"suma": add, "multiplicacion": mult, "division": div}