Question
test average and grade python
Solution
VerifiedAnswered 1 year ago
Answered 1 year ago
Step 1
1 of 2This is the code for a program that can calculate the test average and the grade for each student based on the score.
scores = [("John", 100), ("Mark", 50), ("Ellie", 80), ("Elvis", 40), ("Johny", 66)]
def determine_grade(percentage):
if percentage >= 90:
return 'A'
elif percentage >= 80:
return 'B'
elif percentage >= 65:
return 'C'
elif percentage >= 50:
return 'D'
else:
return 'F'
for score in scores:
grade = determine_grade(score[1])
print(f'{score[0]}: grade={grade}, score={score[1]}')
average = sum(x for x in map(lambda s: s[1], scores)) / len(scores)
print(f"The average score is {average}")
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Recommended textbook solutions

Computer Organization and Design MIPS Edition: The Hardware/Software Interface
5th Edition•ISBN: 9780124077263 (3 more)David A. Patterson, John L. Hennessy220 solutions

Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe687 solutions

Introduction to Algorithms
3rd Edition•ISBN: 9780262033848 (1 more)Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen726 solutions

Introduction to the Theory of Computation
3rd Edition•ISBN: 9781133187790 (1 more)Michael Sipser389 solutions
More related questions
- computer science
- international baccalaureate
- computer science
1/4
- computer science
- international baccalaureate
- computer science
1/7