Question: PYTHON 3 I have to add a for loop to this code that will prompt the user for the number of math questions the user

PYTHON 3

I have to add a for loop to this code that will prompt the user for the number of math questions the user would like to be presented with.

Im just starting Python3 and have a basic grasp how to print and a few basic commands, but Im not sure how to enter this for loop to get the affect it is asking for.

----------------------------------------------------------------

import random

firstnum = random.randrange(1,11) # return an int from 1 to 10

secondnum = random.randrange(1, 11)

compsum = firstnum + secondnum # adds the 2 random numbers together

# print (compsum) # print for troubleshooting

print("What is the sum of", firstnum, " +", secondnum, "?") # presents problem to user

added = int(input("Your answer is: ")) # gets user input

if added == compsum: # compares user input to real answer

print("You are correct!!!")

else:

print ("Sorry, you are incorrect")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!