Question

Trying this question again for the 5th time (Sample Run included).... Currently we are on Chapter...

Trying this question again for the 5th time (Sample Run included)....

Currently we are on Chapter 5 of Pearson's Starting out with PYTHON (Functions)

Write a program that will allow a student to enter their name and then ask them to solve 10 mathematical equations. The program should display two random numbers (from 1 - 500) that are to be added:

Sample run 1:

Enter Student Name: Katie
What is the answer to the following equation? 99 + 221
What is the sum: 435
Wrong

What is the answer to the following equation? 134 + 44
What is the sum: 174
Wrong

What is the answer to the following equation? 408 + 238
What is the sum: 646
Right

What is the answer to the following equation? 222 + 180
What is the sum: 400
Wrong

Information for student: Katie

The number right: 3
The average right is 0.30 or 30.0 %

-> The program should allow the student to enter the answer. The program should then display whether the answer was right or wrong and accumulate the correct values.

-> After the 10 questions are asked, calculate the average correct. Then display the student name, the number correct, and the average correct in both decimal and percentage format.

Homework Answers

Answer #1

import random #import random package for get random numbers using randint method

# random_equation function
def random_equation():   
student_name = input("Enter Student Name: ") # get Student name from user
i=0 #this variable is used while loop exit
right = 0 #this variable is used count right answer
  
# while loop for 10 Questions
while i<10: #check i variable is less than 10
num1 = random.randint(1,500) #get first random number in between 1-500
num2 = random.randint(1,500) #get second random number in between 1-500
print("What is the answer to the following equation?",num1,"+",num2) #Print equation with two random numbers
add = num1 + num2 # add variable is stored correct addition of two random numbers
add_no = int(input("What is the sum: ")) # get answer from user to sum of two random numbers
if add == add_no: #check correct addition and user enter sum is match
right += 1 # then user enter rigth answer increment right variable by one
print("Right") #Print right message
  
else:
print("Wrong") #Print Wrong message
  
  
i += 1 # i is increment by one upto i less than 10
  
print("")   
print("Information of student: ",student_name) #Print student name
print("The number right: ",right) #Print count of right answer
average = (right/10)*100 #calculate average in percentage format
#Print average in decimal and percentage format first is decimal and second is percentage format
print("The average right is: ",(right/10),"or",average,"%")   


random_equation() # call random_equation function
  
  

==================================OUTPUT==========================

==Please Upvote==

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Task #4 Calculating the Mean Now we need to add lines to allow us to read...
Task #4 Calculating the Mean Now we need to add lines to allow us to read from the input file and calculate the mean. Create a FileReader object passing it the filename. Create a BufferedReader object passing it the FileReader object. Write a priming read to read the first line of the file. Write a loop that continues until you are at the end of the file. The body of the loop will: convert the line into a double value...
1.The sample mean is an unbiased estimator for the population mean. This means: The sample mean...
1.The sample mean is an unbiased estimator for the population mean. This means: The sample mean always equals the population mean. The average sample mean, over all possible samples, equals the population mean. The sample mean will only vary a little from the population mean. The sample mean has a normal distribution. 2.Which of the following statements is CORRECTabout the sampling distribution of the sample mean: The standard error of the sample mean will decrease as the sample size increases....
QUESTION 1 1. Brianna is trying to increase her chances of being promoted to vice president...
QUESTION 1 1. Brianna is trying to increase her chances of being promoted to vice president by working to build good work relationships with other managers outside her own department. Brianna's behavior should be viewed as dysfunctional politics. functional politics. coercive power. functional influence. 2 points QUESTION 2 1. The Gingerbread Factory has a separate unit that makes their chocolate crunch cookies and another unit that is completely responsible for all operations in producing their ginger snap cookies. The Gingerbread...
1. What is an ISP (Integrated Service Provider) for supply chains? (1 point) A. A consultant...
1. What is an ISP (Integrated Service Provider) for supply chains? (1 point) A. A consultant agency which integrates the supply chain for companies B. A 2 PL or a 3PL, but not a 4PL C. A company supplying transportation and warehousing services D. A logistics service company specialized in suppling VAS (value added services) 2. What characterizes a 4 PL? (1 point) A. They are non-asset based and provides integrated services primarily supplied by asset based providers, for example...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
Develop a 2018 individual tax return (with all required forms and supporting schedules) for Rob and...
Develop a 2018 individual tax return (with all required forms and supporting schedules) for Rob and Laura Petrie that is both professional in appearance and technically correct. The use of tax software or a professional tax preparer to complete this project is prohibited. You can access fill-in forms (in pdf format) on the IRS website (www.irs.gov) by clicking on “More” on the left side of the homepage in the “Forms and Pubs” section. Next, click on the “Current Forms and...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT