Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the PYTHON partially-completed program for a math tutor program. The instruction is the image attached and the partially-completed Python program is below: # IMPORT

image text in transcribed

Complete the PYTHON partially-completed program for a math tutor program. The instruction is the image attached and the partially-completed Python program is below:

# IMPORT THE FILE NEEDED FOR THE Random CLASS

def main():

# set up some variables to control the program ADD = 0 SUBTRACT = 1 MAXIMUM_VALUE = 100 numCorrect = 0 # Determine how many problems the student wants to do # COMPLETE THIS NEXT LINE. PUT THE USER INPUT INTO A VARIABLE NAMED 'numProblems' int(input('How many math problems would you like to do (1-12)? ') ) # for problem in : # FINISH THE STATMENT TO LOOP ONCE FOR EACH PROBLEM.

# Get two random numbers, num1 and num2, with num 1 >= num2. num1 = # GET A RANDOM NUMBER BETWEEN 1 AND 100.

num2 = # GET A RANDOM NUMBER BETWEEN 0 AND num1.

op = # GET A RANDOM NUMBER 0 OR 1 (0 means ADD; 1 means SUBTRACT).

# Display a problem and calculate the correct answer. if op == ADD: # PRINT THE ADDITION PROBLEM.

rightAnswer = # COMPUTE THE CORRECT ANSWER.

else: # Subtract # PRINT THE SUBTRACTION PROBLEM.

rightAnswer = # COMPUTE THE CORRECT ANSWER.

# Get the user's answer. userAnswer = # INPUT THE USER'S ANSWER. # TEST THE USER'S ANSWER. # IF IT IS CORRECT, SAY SO AND ADD 1 TO numCorrect. # IF IT IS NOT CORRECT, SAY SO AND GIVE THE CORRECT ANSWER

# This is the end of the for loop

# CALCULATE THE % CORRECT THE USER GOT. # IF THE PERCENT CORRECT IS 80% OR HIGHER, PRINT "Congratulations!" # TELL THE USER HOW MANY WERE CORRECT OUT OF HOW MANY ATTEMPTED # AND WHAT PERCENT WERE CORRECT. # This is the end of the main method # call main to run the program main()

2. The UPPERCASE COMMENTS indicate places where you need to write Python code. For each such comment, you may need to complete a partially-written statement, or you may need to write one or more statements. 3. Save the program and try to run it. You may have issues with indentation. I used tabs when I created the program, so spaces and tabs don't mix well. Find the places where this is happening and try to fix them. Run the program. Test it with 8 problems. You should have a mix of addition and subtraction problems. In every case, the second number should be 4. the first number. Here are two sample runs of the program: How many math problems would you like to do (1-12)? 3 31 + 6 Your answer? 37 Correct! 57 34 Your answer? 33 The answer was 23 68 +4 Your answer? 72 Correct! You got 2 out of 3 correct, which is 66.66666666666666 %

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

3 > O Actual direct-labour hours Standard direct-labour hours...

Answered: 1 week ago