extra_attempts_divide = 0

for x in range(attempts):

    num1 = random.randint(0, 9)
    num2 = random.randint(0, 9)
    operator = random.randint(1, 4)
    print("What is .....\n")

    if operator == 1:
        total_addition += 1
        myfunctions.printNum(num1, size)
        print(myfunctions.plus(5))
        myfunctions.printNum(num2, size)
        answer = int(input("= "))
        print(myfunctions.check_answer(num1, num2, answer, "+"))
        if answer == num1 + num2:
            total_score += 1
            correct_addition += 1
        while drill_mode == "yes" and myfunctions.check_answer(
                num1, num2, answer, "+") != "Correct!\n":
            answer = int(input("= "))
            print(myfunctions.check_answer(num1, num2, answer, "+"))
            extra_attempts_add += 1

    elif operator == 2:
        total_subtraction += 1
        myfunctions.printNum(num1, size)
        print(myfunctions.minus(5))
        myfunctions.printNum(num2, size)
        answer = int(input("= "))
Exemple #2
0
    num +=1
    print ("What is .....")
    a = random.randint(0,9)
    b = random.randint(0,9)
    c = random.randint(1,2)
    myfunctions.print_number(a, width)
    if c == 1:
        print (myfunctions.plus(width))
        c = "+"
    else:
        print(myfunctions.minus(width))
        c="-"
    myfunctions.print_number(b,width)
    problem_answer = int(input("= "))

    check_problem = myfunctions.check_answer(a,b,problem_answer,c)
    if check_problem == True:
        correct_answers += 1
        print("Correct!")

    elif check_problem == False:
        print ("Sorry, that's not correct.")

print ()
print ("You got ", correct_answers, "out of ", problems, "correct!")

        
   


    
    print()
    myfunctions.print_operator(operator, digit, character)
    print()

    #draw second number
    myfunctions.print_number(num2, digit, character)

    #processing and counting based on whether drill mode or not
    #drillmode
    if drill == "yes":
        wronganswer = True
        while wronganswer:
            #get user's guess
            useranswer = int(input("= "))
            #check if cororect answer
            if myfunctions.check_answer(num1, num2, useranswer,
                                        operator) == True:
                print("Correct!")
                wronganswer = False
            else:
                print("Sorry, that's not correct.")
                #counting attempts
                if operator == "plus":
                    addattempts += 1
                elif operator == "minus":
                    subattempts += 1
                elif operator == "times":
                    multattempts += 1
                elif operator == "divide":
                    divattempts += 1

    #not drill mode
                    myfunctions.plus(w)
                    print()
                else:
                    print()
                    print()
                    operation = "-"
                    myfunctions.minus(w)
                    print()
                    print()

            elif i == 1:
                secondNum += randNum
                myfunctions.number_9(w)

    # user enters their answer
    answer = int(input("= "))

    # calls function from external module to validate user answer
    ans = myfunctions.check_answer(firstNum, secondNum, answer, operation)

    if ans == True:
        print("Correct!")
        correct += 1
    else:
        print("Sorry, that's not correct.")

print()

# tells user how many questions they got right
print("You got", correct, "out of", problems, "correct!")
    elif b == 2:
        myfunctions.number_2(w)
    elif b == 3:
        myfunctions.number_3(w)
    elif b == 4:
        myfunctions.number_4(w)
    elif b == 5:
        myfunctions.number_5(w)
    elif b == 6:
        myfunctions.number_6(w)
    elif b == 7:
        myfunctions.number_7(w)
    elif b == 8:
        myfunctions.number_8(w)
    elif b == 9:
        myfunctions.number_9(w)

    entered_answer = int(input("= "))
    if myfunctions.check_answer(a, b, entered_answer, op) == True:
        print("Correct! ")
        total_right += 1
    elif myfunctions.check_answer(a, b, entered_answer, op) == False:
        print("Sorry, that's not correct. ")
    print()
    print()
    if question_n == problem_n:
        print("You got", total_right, "out of", problem_n, "correct!")
    question_n += 1
    print()
    print()
Exemple #6
0
        myfunctions.number_5(width)
    elif y == 6:
        myfunctions.number_6(width)
    elif y == 7:
        myfunctions.number_7(width)
    elif y == 8:
        myfunctions.number_8(width)
    elif y == 9:
        myfunctions.number_9(width)

    # Asking user for answer
    print("=", end="")
    user_answer = int(input())

    # Checking answer
    answer = myfunctions.check_answer(x, y, user_answer, z)
    if drill == "yes":
        while answer == False:
            print("Sorry, that's not correct.")
            # Ask again
            print("=", end="")
            user_answer = int(input())
            answer = myfunctions.check_answer(x, y, user_answer, z)
        print("Correct!")
        print()
        continue
    if answer == True:
        correct_answers += 1
        print("Correct!")
    elif answer == False:
        print("Sorry, that's not correct.")
correct = 0


for problem in range(num_problems):
    print("What is .....")
    print()
    int1 = random.randint(0,9)
    int2 = random.randint(0,9)
    op = random.randint(1,2)

    myfunctions.print_number(int1, width, character)
    print()

    if op == 1:
        print(myfunctions.plus(width, character))
        real_ans = myfunctions.check_answer(int1,int2,(int1+int2),'+')
    else:
        print(myfunctions.minus(width, character))
        real_ans = myfunctions.check_answer(int1,int2,(int1-int2),'-')
        
    print()
    myfunctions.print_number(int2,width, character)

    if op == 1:
        user_ans = int(input('= '))
        user_check = myfunctions.check_answer(int1,int2,user_ans,'+')
        if user_check == real_ans:
            print("Correct!")
            print()
            correct += 1
            continue
Exemple #8
0
     print(myfunctions.minus(width, character))
     print()
     subtract_questions += 1
 elif operator == "*":
     print(myfunctions.multiply(width, character))
     multiply_questions += 1
 elif operator == "/":
     print(myfunctions.divide(width, character))
     divide_questions += 1
 myfunctions.print_number(number2, width, character)
 # prompt the user to enter an answer for each problem
 answer = int(input("= "))
 # if the user activates drill mode, when the user gets incorrect,
 # ask the user to enter another answer until the correct answer is supplied
 if drill == "yes":
     while not myfunctions.check_answer(number1, number2, answer, operator):
         print("Sorry, that's not correct.")
         answer = int(input("= "))
         # keep track of the number of extra attempts the user takes for each type of mathematical operations
         if operator == "+":
             add_extra_attempts += 1
         elif operator == "-":
             subtract_extra_attempts += 1
         elif operator == "*":
             multiply_extra_attempts += 1
         elif operator == "/":
             divide_extra_attempts += 1
     print("Correct!")
 # if the user doesn't activate drill mode, check if the answer is correct and tell the user
 else:
     if myfunctions.check_answer(number1, number2, answer, operator):