Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Explain how labour relations practices differ around the world.

Answered: 1 week ago