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
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
COSC 1436 Programming Assignment 2 Programming Assignment 2 Refactoring is the process of taking existing code...
COSC 1436 Programming Assignment 2 Programming Assignment 2 Refactoring is the process of taking existing code and improving its design without changing the functionality. In this programming assignment, you are going to take your code from Programming Assignment 1 and refactor it so that it uses functions. The program should still do the following:  Get the name of a student  Get the name of three assignments  Get the grade of three assignments as integers  Calculates the...
1. Create a new project. Type in the following program. Add a comment at the top...
1. Create a new project. Type in the following program. Add a comment at the top to include your name and the date. 2. Compile and Run with different values. What data values should you choose? Think about what we discussed in class. 3. Add code to compute the modulus. Hint: you will also have to declare a new variable. //this program demonstrates the use of various operators #include <iostream > using namespace std; int main() { int num1; int...
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...
If you cant answer this please dont waste my question. thank you. This cryptographic program run...
If you cant answer this please dont waste my question. thank you. This cryptographic program run and produce text screen output. You are to create a GUI that uses the program. Your program (GUI) must allow a user to input of a message to be coded. It must also have an area to show the plaintext, the ciphertext, and the decrypted text. If required by your choice of cryptographic method, the user should have an area to input a key....
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...