How can I simplify repetitive if-elif statements in my grading system function?
问题 The goal is to build a program to convert scores from a '0 to 1' system to an 'F to A' system: If score >= 0.9 would print 'A' If score >= 0.8 would print 'B' 0.7, C 0.6, D And any value below that point, print F This is the way to build it and it works on the program, but it's somewhat repetitive: if scr >= 0.9: print('A') elif scr >= 0.8: print('B') elif scr >= 0.7: print('C') elif scr >= 0.6: print('D') else: print('F') I would like to know if there is a way to build a function so that the