Python Forum
GPA Calculator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: GPA Calculator (/thread-15416.html)



GPA Calculator - Aldmonjoy - Jan-16-2019

Hello! I am new to Python and am trying to make a GPA calculator. I have what it should look like in my head but don't know how to actually do it. I would like it so the person can put in how many classes they are in and, when they do, that many user inputs will pop up so they can enter their grades. But I do not know how to get it to do this. For example, if they are in 6 classes I would like it to print "Enter Grade Here: " six times. And then they may enter their grades. I would like the same thing to happen with class credits.


RE: GPA Calculator - ichabod801 - Jan-16-2019

Entering the number of classes would use input(). However, input returns a string, which you would need to convert to an integer with int(). Then you would start with an empty list of grades, make a range() of the number of classes, and loop through that with a for loop. Each time through the loop, input() the next grade and append it to the list of grades.