Пример #1
0
 def __init__(self):
     self.lhs_min = 1
     self.lhs_max = 12
     self.rhs_min = 1
     self.rhs_max = 12
     self.operation = Operation.multiplication()
     self.number_of_questions = 100
Пример #2
0
    def promptCustom(self):
        print("Which operation do you want?")
        print("  1. Multiplication")
        print("  2. Addition")
        print("  3. Subtraction")
        print("  4. Division")

        text = input("Operation: ")
        op_choice = int(text)
        op_choices = {
            1: Operation.multiplication(),
            2: Operation.addition(),
            3: Operation.substraction(),
            4: Operation.division()
        }

        OPERATION = op_choices.get(op_choice, Operation.multiplication())
#
        text = input("Left hand side start: ")
        LHS_START = int(text)

        text = input("Left hand side end: ")
        LHS_END = int(text)

        text = input("Right hand side end: ")
        RHS_START = int(text)

        text = input("Right hand side end: ")
        RHS_END = int(text)

        text = input("Number of questions: ")
        NUMBER_OF_QUESTIONS = int(text)

        result = UserOptions()
        result.operation = OPERATION
        result.lhs_min = LHS_START
        result.lhs_max = LHS_END
        result.rhs_min = RHS_START
        result.rhs_max = RHS_END
        result.number_of_questions = NUMBER_OF_QUESTIONS
        return result
Пример #3
0
    except ValueError:
        print("not a number! please try again")
        continue

while True:
    second_number = input("input second number: ")
    try:
        second_number = int(second_number)

    except ValueError:
        print("not a number! please try again")
        continue
    if second_number == 0 and operation == '/':
        print("thats illegal..")
    else:
        break
if operation == '+':
    Operation.addition(first_number, second_number)

elif operation == '-':
    Operation.subraction(first_number, second_number)

elif operation == '/':
    Operation.division(first_number, second_number)

elif operation == '*':
    Operation.multiplication(first_number, second_number)

else:
    print("surprise! Theres a flaw in the logic -_-")