scores ={'James':94,'John':79,'Tomas':46,'Bob':60}
print(scores)
if 80 < score <= 100:
print("'s grade is A.")
elif 60 < score <=80:
print('Your grade is B.')
elif 40 < score <=60:
print('The grade is C.')
elif 20 < score <=40:
print('The grade is D.')
else :
print('The grade is F.')
I think I can combine these two well, but it's hard
python
scores = {'James':94,'John':79,'Tomas':46,'Bob':60}
from typing import Callable
f:Callable[[tuple], str] = lambda score:{80 <score[1] <=100:f'{score[0]} is A',60 <score[1] <=80:f'{score[0]} is B',40 <score[1];20;<<<<<&score[0] is a score [0]:40;20];<<<<<<[True]
list(map(f, scores.items()))
["James is A", "John is B", "Tomas is C", "Bob is C"]
Just keep that in mind.
scores = {'James':94,'John':79,'Tomas':46,'Bob':60}
f = lambda score:{80<score[1] <=100:f'{score[0]} is A',60<score[1] <=80:f'{score[0]} is B',40<score[1] <60:f'{score[0] is 20', 20:f'{score[0]'[True]
[f(score) for score in scores.items()]
["James is A", "John is B", "Tomas is C", "Bob is C"]
© 2025 OneMinuteCode. All rights reserved.