Advertisement
Spocoman

02. Grades

Jan 25th, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. grade = float(input())
  2.  
  3. output = {2.00 <= grade <= 2.99: "Fail",
  4.           3.00 <= grade <= 3.49: "Poor",
  5.           3.50 <= grade <= 4.49: "Good",
  6.           4.50 <= grade <= 5.49: "Very Good",
  7.           5.50 <= grade <= 6.00: "Excellent"}
  8.  
  9. def solve():
  10.     if 2 <= grade <= 6:
  11.         return output[True]
  12.  
  13. print(solve())
  14.  
  15.  
  16. Или:
  17.  
  18. grade = float(input())
  19.  
  20. def solve():
  21.     if 2 <= grade <= 6:
  22.         return {2.00 <= grade <= 2.99: "Fail",
  23.                 3.00 <= grade <= 3.49: "Poor",
  24.                 3.50 <= grade <= 4.49: "Good",
  25.                 4.50 <= grade <= 5.49: "Very Good",
  26.                 5.50 <= grade <= 6.00: "Excellent"}[True]
  27.  
  28. print(solve())
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement