Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the flowchart and correct python code for the following program based on

ID: 3669956 • Letter: W

Question

What is the flowchart and correct python code for the following program based on this pseudocode?

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.

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

Explanation / Answer

See the below code in python written as per given problem statement.

1. Cretaed methods for solving mathematical equations.

2. Justified answer is right or wrong with prompt.

3. Calculated the average score and printed the result..

operators = ["/","-","+","*"]

def computation( numbers,operator ):
if operator == "/":
return numbers[0]/numbers[1]
if operator == "-":
return numbers[0]-numbers[1]
if operator == "+":
return numbers[0] + numbers[1]
if operator == "*":
return numbers[0] + numbers[1]

def createquestion():
global operators
number1 = 1 + int(random()*1000)
number2 = 1 + int(random()*1000)
operator = operators[int(random()*4)]
answer = computation( [number1,number2],operator )
questionstr = str(number1)+operator + str(number2)
return [questionstr,answer]

answers = []

count=1
studentname = raw_input("Enter your name ")
while count <= 10:
print "This is question number ",count
qa = createquestion()
print qa[0]
studentanswer = raw_input("What is your answer")
if qa[1] == int(studentanswer ):
answers.append("correct")
else:
answers.append("wrong")
count+=1
correctanswers = sum([1 for x in answers if x =="correct"])
print "Summary"
print "Name of the student:",studentname
print "number of correct answers:",correctanswers
print "percentage correct is :",correctanswers*10
print "average of correct answers is :",float(correctanswers)/10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote