예제 #1
0
 def add(self, a, b):
     self.result = addition(a, b)
     return self.result
예제 #2
0
def get_y_n_answer():
    while True:
        try:
            letter = input("Would you like to make another calculation (Y,N): ")
            if letter != 'Y' and letter != 'y' and letter != 'N' and letter != 'n':
                raise ValueError
            break
        except ValueError:
            print("Oops!  That was no valid symbol.  Try again...")

    return letter


while True:

    operator_symbol = get_operator_symbol()

    if operator_symbol == '+':
        print("Result: " + str(round_number_ceil(addition(get_number_input(), get_number_input()))))
    elif operator_symbol == '-':
        print("Result: " + str(round_number_ceil(subtraction(get_number_input(), get_number_input()))))
    elif operator_symbol == '*':
        print("Result: " + str(round_number_ceil(multiplication(get_number_input(), get_number_input()))))
    elif operator_symbol == '/':
        print("Result: " + str(round_number_ceil(division(get_number_input(), get_number_input()))))

    answer_letter = get_y_n_answer()
    if answer_letter == 'N' or answer_letter == 'n':
        break