Question: # Import the students variable from data.py from data import students def calculate _ adjusted _ total ( exam _ scores ) : # Sort

# Import the students variable from data.py
from data import students
def calculate_adjusted_total(exam_scores):
# Sort the scores and take the best two
best_two_scores = sorted(exam_scores, reverse=True)[:2]
# Calculate the average of the best two scores
adjusted_total = round(sum(best_two_scores)/2)
return adjusted_total
def calculate_letter_grade(adjusted_total):
# Determine the letter grade based on the adjusted total
if adjusted_total >=90:
return 'A'
elif adjusted_total >=80:
return 'B'
elif adjusted_total >=70:
return 'C'
else:
return 'F'
# Print header
print(f"{'FirstName':<12}{'LastName':<12}{'AdjTotal':<12}{'Grade':<12}")
# Process each student
for student in students:
first_name = student['FirstName']
last_name = student['LastName']
exam_scores = student['ExamScores']
# Calculate adjusted total and letter grade
adj_total = calculate_adjusted_total(exam_scores)
grade = calculate_letter_grade(adj_total)
# Print only students with an 'A' grade
if grade =='A':
print(f"{first_name:<12}{last_name:<12}{adj_total:<12}{grade:<12}")

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 Programming Questions!