Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

' ' ' Please write code that can be used below my current output, that will take the current overall score that is outputted at

'''
Please write code that can be used below my current output, that will take the current overall score that is outputted at the end and then write a function,
to tell the user the specific score that they need on the final exam (with the final exam grade weight taken into account),
to achieve each possible overall letter grade in the course (A - D)
'''
def get_weights(num_tests):
test_weights =[]
for i in range(1, num_tests +1):
weight = float(input(f"Percentage weight of Test {i}: "))
test_weights.append(weight)
return test_weights
def get_scores(num_tests):
test_scores =[]
for i in range(1, num_tests +1):
score = float(input(f"Test {i} score: "))
test_scores.append(score)
return test_scores
def calculate_current_score(test_scores, test_weights, homework_weight, homework_score, programs_weight, programs_score):
current_score = sum(score *(weight /100) for score, weight in zip(test_scores, test_weights))
if homework_weight >0:
current_score += homework_score *(homework_weight /100)
if programs_weight >0:
current_score += programs_score *(programs_weight /100)
return current_score
def main():
num_tests = int(input("How many tests were given? "))
test_weights = get_weights(num_tests)
final_weight = float(input("Percentage weight of Final: "))
homework_weight = float(input("Percentage weight of Homework (0 for no hw): "))
programs_weight = float(input("Percentage weight of Programs (0 for no pgms): "))
total_weight = sum(test_weights)+ final_weight + homework_weight + programs_weight
if total_weight !=100:
print("The total weight of all components must be 100.")
return
test_scores = get_scores(num_tests)
homework_score = float(input("Homework Average: ")) if homework_weight >0 else 0
programs_score = float(input("Program Average: ")) if programs_weight >0 else 0
current_score = calculate_current_score(test_scores, test_weights, homework_weight, homework_score, programs_weight, programs_score)
print(f"Your current numeric score in the class (without the final) is {current_score:.1f}")
if current_score >=90:
current_grade ='A'
elif current_score >=80:
current_grade ='B'
elif current_score >=70:
current_grade ='C'
elif current_score >=60:
current_grade ='D'
else:
current_grade ='E'
print(f"Without the final final you would get a \"{current_grade}\" in the class")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions