
Concept explainers
PART I: Functions – Math Test
Write the Flowchart and Python code for the following
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 that are to be added, such as:
247
+ 129
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.
In addition to any system functions you may use, you might consider the following functions:
- A function that allows the student to enter their name.
- A function that gets two random numbers, anywhere from 1 to 500.
- A function that displays the equation and asks the user to enter their answer.
- A function that checks to see if the answer is right and accumulates the number right.
- A function that calculates the results.
- A function that displays the student name, the number right, and the average right.
Your sample output might look as follows (random numbers will be different):
Enter Student Name: Katie
What is the answer to the following equation
424
+
28
What is the sum: 472
Wrong
What is the answer to the following equation
163
+
233
What is the sum: 396
Right
What is the answer to the following equation
285
+
453
What is the sum: 688
Wrong
Etc…(through 10 iterations)
Information for student: Katie
The number right: 5
The average right is 0.50 or 50.0 %
The Pseudocode
Module main()
//Declare local variables
Declare Integer counter = 0
Declare String studentName = “NO NAME”
Declare Real averageRight = 0.0
Declare Real right = 0.0
Declare Integer number1 = 0
Declare Integer number2 = 0
Declare answer = 0.0
Set studentName = inputNames()
//Loop to run program again
While counter < 10
//calls functions
Call getNumbers(number1, number2)
Set answer = getAnswer(number1, number2, answer)
Set right = checkAnswer(number1, number2, answer, right)
Set counter = counter + 1
End While
Set averageRight = results(right, averageRight)
Call displayInfo(right, averageRight, studentName)
End Module
Function String inputNames(String studentName)
Display “Enter Student Name:”
Input studentName
Return studentName
End Function
Module getNumber(Integer Ref number1, Integer Ref number2)
Set number1 = random(1, 500)
Set number2 = random(1, 500)
End Module
Function Integer getAnswer(Integer number1, Integer number2, Integer answer)
Display “What is the answer to the following equation”
Display number1
Display “+”
Display number2
Display “What is the sum:”
Input answer
Return answer
End Function
Function Integer checkAnswer(Integer number1, Integer number2, Integer answer, Integer right)
If answer == number1 + number2 then
Display “Right”
Set right = right + 1
Else
Display “Wrong”
End If
Return right
End Function
Function Real results (Integer right, Real AverageRight)
Set averageRight = right / 10
Return averageRight
End Function
Module displayInfo(Integer right, Real averageRight, String studentName)
Display “Information for student:”, studentName
Display “The number right:”, right
Display “The average right is:”, averageRight
End Module
The Flowchart
PASTE FLOWCHART HERE
The Python Code
PASTE CODE HERE AND SCREEN SHOT CODE RUNNING

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

- Python code of part b pleasearrow_forwarder 6 Functions Programming Exercises te 1. Rectangle Area ngle Area The area of a rectangle is calculated according to the following formula: Area = Width X Length Design a function that accepts a rectangle's width and length as arguments and returns the rectangle's area. Use the function in a program that prompts the user to enter the rectangle's width and length, and then displays the rectangle's area.arrow_forwardCoin Toss Write a function named coinToss that simulates the tossing of a coin. When you call the function, it should generate a random number in the range of 1 through 2. If the random number is 1, the function should display "heads". If the random number is 2, the function should display "tails". Demonstrate the function in a program that sks the user how many times the coin should be tossed and the coin then simulates the tossing of the coin that number of times.arrow_forward
- Python Programming Only (PLEASE INCLUDE INPUT VALIDATION IF NEEDED) Write a function named maximum that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if two numbers are one big and one small the function should return the bigger number. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two.arrow_forwardProgram Unit Score Calculator Console App Write a Python Console Application program that allows the user to enter the marks for different assessments in a unit, and computes the total mark and grade for the unit. Here is the program logic specification: There are six assessment activities Quiz1, Quiz2, Quiz3, Quiz4, Lab Journal, Major Assignment and Final Exam. The four quizzes are worth 5 marks each, the Lab Journal is worth 10 marks, the Major Assignment is worth 30 marks and the Final Exam is worth 40 marks. The algorithm for computing the total mark for the unit is: Total Mark = Quiz1+Quiz2+Quiz3+Quiz4+Major Assignment+ Lab Journal + Final Exam The following screenshot shows a successful test run:arrow_forwardWhat is the Pseudocode?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





