Exemplo n.º 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()
Exemplo n.º 2
0
    Addition              -->  1     Subraction      -->  2
    Multiplication        -->  3     Division        -->  4
    Integer Division      -->  5     Power           -->  6
    Modulo                -->  7     Log             -->  8
    Sigmoid of sum        -->  9     Random Number   -->  10
    Highest common factor --> 11     Factorial (of first number) --> 12
    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:
Exemplo n.º 3
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
Exemplo n.º 4
0
 #print menu
 print("{:_^20}").format("")
 print("1. Addition")
 print("2. Subtraction")
 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):
Exemplo n.º 5
0
 def test_addition(self):
     self.assertEqual(operations.addition(70, 2), 72)
Exemplo n.º 6
0
def calc_hypotenuse(_side_a, _side_b):
    """ Calculates hypotenuse using theorem """
    return square_root(addition(power(_side_a, 2), power(_side_b, 2)))