scipiguy

Logical Expressions and Python - Using comparison operators

Oct 28th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. testscore = int(input("What percent did the student achieve? "))    
  2. while testscore < 0 or testscore > 100:
  3.     testscore = int(input("What percent did the student achieve? "))
  4.    
  5. if testscore >= 80:
  6.     grade = "A"
  7. elif testscore >= 70:
  8.     grade = "B"
  9. elif testscore >= 60:
  10.     grade = "C"
  11. elif testscore >= 50:
  12.     grade = "D"
  13. elif testscore >= 40:
  14.     grade = "E"
  15. else:
  16.     grade = "U"
  17.    
  18. print("A percentage of " + str(testscore) +" gains you a grade " + grade)
Advertisement
Add Comment
Please, Sign In to add comment