0% found this document useful (0 votes)
242 views5 pages

Other Instructions Will Be Provided by The Instructor: Assignment #8

The document provides instructions for an assignment to write a Python program that asks a student to solve 10 math problems by adding random two-digit numbers. The program should display the student's name, number of correct answers, and average percentage correct. Functions are suggested to get the student's name, generate random numbers, display problems and get answers, check answers, calculate results, and display output. Pseudocode and a Python program implementing the described functionality are provided.

Uploaded by

Mada Anudeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
242 views5 pages

Other Instructions Will Be Provided by The Instructor: Assignment #8

The document provides instructions for an assignment to write a Python program that asks a student to solve 10 math problems by adding random two-digit numbers. The program should display the student's name, number of correct answers, and average percentage correct. Functions are suggested to get the student's name, generate random numbers, display problems and get answers, check answers, calculate results, and display output. Pseudocode and a Python program implementing the described functionality are provided.

Uploaded by

Mada Anudeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CSD 1133 Problem Solving/Program Logic

Assignment #8
Chapter 9: Program Modules, Subprograms, and Functions

Other Instructions will be provided by the instructor


Write the Flowchart and Python code for the following programming problem based on the pseudocode
below.
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.

Program:

import random

counter = 10
studentName = input("Student Name: ")
rightAnswer = 0
studentAnswer = 0
number1 = 0
number2 = 0
right = 0
wrong = 0
averageRight = 0
for i in range(1, counter + 1):
number1 = random.randint(1, 500)
number2 = random.randint(1, 500)
rightAnswer = number1 + number2
print(number1)
print("+")
print(number2)
studentAnswer = int(input("What is the Sum: "))
if studentAnswer == rightAnswer:
print("Right\n")
right += 1
else:
print("Wrong\n")
wrong += 1
else:
averageRight = float((right / counter) * 100)

print("Student Name: ", studentName)


print("Number of Right answers: ", right)
print("Number of Wrong answers: ", wrong)
print("The average of right answers: ", averageRight)
Output:
Flowchart:
Input names Extension

getNumbers extension

Getanswer extension

Check answers extension


Result extension

Display info extension

You might also like