Question: How would one create a flowchart in flowgorithm with the following code? ( Code is in Python ) import random def toFixed ( value ,

How would one create a flowchart in flowgorithm with the following code? (Code is in Python)
import random
def toFixed(value, digits):
return "%.*f"%(digits, value)
random.seed() # Prepare random number generator
# Function to get valid scores
def get_score(prompt):
while True:
print(prompt)
score = float(input())
if 0<= score <=100:
return score
# Get three scores from the user
Grade1= get_score("The first grade could be from 0 to 100")
Grade2= get_score("The second grade could be from 0 to 100")
Grade3= get_score("The third grade could be from 0 to 100")
sum = Grade1+ Grade2+ Grade3
PossibleGrades =[999]*4
grades =['A','B','C','D']
grade_limits =[360,320,280,240]
probability =[0]*4
# Determine the minimum scores needed for each grade
if 360- sum <=100:
PossibleGrades[0]=400*0.9- sum
if 320- sum <=100:
PossibleGrades[1]=400*0.8- sum
if 280- sum <=100 and 400*0.7- sum >0 and 400*0.7- sum <=100:
PossibleGrades[2]=400*0.7- sum
if 240- sum <=100 and 400*0.6- sum >0 and 400*0.6- sum <=100:
PossibleGrades[3]=400*0.6- sum
# Calculate probabilities for each grade
for _ in range(10000):
x = int(random.random()*101)
for Index in range(4):
if x >= PossibleGrades[Index]:
probability[Index]+=1
# Print combined statements
for Index in range(4):
if PossibleGrades[Index]!=999:
prob = toFixed(probability[Index]/100,1)
min_score = PossibleGrades[Index]
grade = grades[Index]
print(f"You have a {prob}% of probability to obtain {grade} with a minimum score of {min_score}")
if sum <240:
print("It is not possible to pass the course.")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!