137k views
5 votes
Project: Math Tutor Program with Error Handling

image of a man sitting on a branch he is about to cut off

Sawing off the branch you are sitting on can only end badly (Imagery supplied by photoschmidt/iStock via Getty)
Unlike the man in the picture, you already know how to plan for and handle errors before they happen. You know how to create and use lists. You know how to use loops. You are going to put these abilities to work in this project. You are going to write a program to help young children with their arithmetic skills.

Objectives
Plan and create a program to practice math facts with error handling.

Your Goal
Your users are young children learning their arithmetic facts. The program will give them a choice of practicing adding or multiplying.

You will use two lists of numbers.

numA = [4, 1, 6, 10, 2, 3, 7, 9, 11, 12, 5, 8]

numB = [2, 12, 10, 11, 1, 3, 7, 9, 4, 8, 5, 6]

If the user chooses adding, you will ask them to add the first number from each list. Tell them if they are right or wrong. If they are wrong, tell them the correct answer.
Then ask them to add the second number in each list and so on.

If the user chooses multiplying, then do similar steps but with multiplying.

Whichever operation the user chooses, they will answer 12 questions.

Write your program and test it on a sibling, friend, or fellow student.

Errors
Think about the types of errors a user can make. Add at least one kind of error handling to your program.

What to Submit
Save your program with a .txt extension. You cannot upload a .py file.
Before you turn your project in, read the rubric.

I need this to be original work

User Roostaamir
by
8.4k points

1 Answer

4 votes

Answer:

finished = False

numA = [4, 1, 6, 10, 2, 3, 7, 9, 11, 12, 5, 8]

numB = [2, 12, 10, 11, 1, 3, 7, 9, 4, 8, 5, 6]

while True:

pick = input("Would you like to practice addition (+) or multiplication (*)?")

if pick == "+":

for o, k in zip(numA, numB):

ans = input(f"What is {o} + {k}?")

if ans == str(o + k):

print('Correct!\\')

else:

print(f"Incorrect! The correct answer was {o + k}\\")

finished = True

elif pick == "*":

for o, k in zip(numA, numB):

ans = input(f"What is {o} * {k}?")

if ans == str(o * k):

print('Correct!\\')

else:

print(f"Incorrect! The correct answer was {o * k}\\")

finished = True

else:

print('Incorrect Input!')

if finished:

print('Thanks for playing!')

break

Step-by-step explanation:

aduhhhh

User Linski
by
8.2k points