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"]
589 Uncaught (inpromise) Error on Electron: An object could not be cloned
573 PHP ssh2_scp_send fails to send files as intended
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
863 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.