Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GPA Calculator
#1
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.
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020