Your GPA, or Grading Point Average, is an average of all the grades of a student, calculated by assigning each letter grade a numerical value (for instance, an A has a value of `4.0`). A GPA is always between `0.0` and `4.0`.
Write a program called `validgpa.py` that uses a `while` loop to repeatedly ask the user to enter a valid unweighted GPA (a floating point number between `0.0` and `4.0`). Print “Invalid.” and try again if the given GPA is invalid and print “Thanks.” if the GPA is valid.
-!- CODE language-text -!-Enter a valid unweighted GPA: -9
Enter a valid unweighted GPA: 20.3
Enter a valid unweighted GPA: 3.7
CodeGrade is your virtual teaching assistant in your Python classroom. You teach, CodeGrade takes care of the rest.
Our 35 built-in fully automatically graded Introduction to Programming assignments are designed especially for middle school and high school coding education, in close collaboration with Harvard-Westlake School (Los Angeles, CA). You can start teaching Python at your school with confidence now. Or, easily scale your classroom with CodeGrade's tools.
Book a personal 30-minute demo now and we'll show you how to get started with CodeGrade in less than 1 hour!