This is a program that can calculate, the GPA of a student on a 5.0 scale,it's written in python 3.x and no modules are required.
GPA Calculator
"""THIS A GPA CALCULATOR, IT TAKES THE SEMESTER
OF THE STUDENTS, THE NO OF COURSES, AND THE
COURSE UNITS AND RESPECTIVE GRADES,
AND PRINTS THE SEMESTER AND THE GPA
BY ADEGOKE OBASA,
adegokeobasa@yahoo.com """
#function to convert grade to grade point starts
def conv(g):
if g=='A' :
return 5
elif g=='B':
return 4
elif g=='C':
return 3
elif g=='D':
return 2
elif g=='E':
return 1
elif g=='F':
return 0 #function to convert grade to grade point ends
#function that calculate the gpa based using while loop
def gpa(c_no):
k=0
tlu=0
t=0
while k!=c_no:
k=k+1
c=int(input('Course unit')) #this line gets the unit for the course
g=input('Course grade') #this line gets the grade for the course
tlu=c*conv(g)+tlu
t=t+c
gpa=round(tlu/t,2) #this line computes the gpa
print('You are in',sem,'Semester and your GPA is' ,gpa) #this line outputs the gpa and the semester
#function ends here
#this line tells the user the purpose of the program
print('This Program calculates the GPA of Students')
#this line tells the user the limitations of the program
print('The maximum amount of courses that this program can accept is 10 and the minimum is 2')
#this line prompts the user for the semester
sem=input('Which Semester')
#this line prompts the user for the number of courses offered that semester
c_no=int(input('Number of courses offered'))
if c_no==2: #if the no of courses inputed is 2
gpa(2)
elif c_no==3: #if the no of courses inputed is 3
gpa(3)
elif c_no==4: #if the no of courses inputed is 4
gpa(4)
elif c_no==5: #if the no of courses inputed is 5
gpa(5)
elif c_no==6: #if the no of courses inputed is 6
gpa(6)
elif c_no==7: #if the no of courses inputed is 7
gpa(7)
elif c_no==8: #if the no of courses inputed is 8
gpa(8)
elif c_no==9: #if the no of courses inputed is 9
gpa(9)
elif c_no==10: #if the no of courses inputed is 10
gpa(10)
else:
pass
e-papa 13 Posting Pro in Training
woooee 814 Nearly a Posting Maven
e-papa commented: Cool comment, hope to help others like you someday +1
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
woooee 814 Nearly a Posting Maven
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.