EvilZone
Programming and Scripting => Projects and Discussion => : IrishYoga January 19, 2013, 12:18:02 AM
-
So i've generated my own python gpa calculator, or that's what it'll be in the end, at least. So far, all i've been able to do is bring in the raw_input from the users and make it calculate your average. But what i want to do, is get a 93, for example and make it print the gpa. How do i make python do this?
-
You might have to define each gpa and the associated grade and then compare it to the average
-
a =int (raw_input('Enter grade: '))
b =int (raw_input('Enter grade: '))
c =int (raw_input('Enter grade: '))
d =int (raw_input('Enter grade: '))
e =int (raw_input('Enter grade: '))
f =int (raw_input('Enter grade: '))
g =int (raw_input('Enter grade: '))
h =int (raw_input('Enter grade: '))
cumalitive = a,b,c,d,e,f,g,h
one = a+b+c+d+e+f+g+h
two = one/len(cumalitive)
GPA='defined'
if two<0 or two>100:
GPA<0
if two>=97 and two<=100:
GPA=4.0
elif two>=93 and two<=96:
GPA=4.0
elif two >=90 and two<=92:
GPA=3.7
elif two>=87 and two<=89:
GPA=3.3
elif two>=83 and two<=86:
GPA=3.0
elif two>=80 and two<=82:
GPA=2.7
elif two>=77 and two<=79:
GPA=2.3
elif two>=73 and two<=76:
GPA=2.0
elif two>=70 and two<=72:
GPA=1.7
elif two>=67 and two<=69:
GPA=1.3
elif two>=65 and two<=66:
GPA=1.0
elif two<65 and two>0:
GPA=0.0
if two>0 and two<=100 and GPA>0:
print '\n'
print 'your grade is'
print two
print 'your gpa is: '
print GPA
else:
print '\n'
print 'not valid grades'
it's only able to input 8 grades right now, but i will modify it to keep adding raw_Inputs and since 'two' divides by the length of whatever the length of 'cumalitive' is, then it will be really easy.
-
a =int (raw_input('Enter grade: '))
b =int (raw_input('Enter grade: '))
c =int (raw_input('Enter grade: '))
d =int (raw_input('Enter grade: '))
e =int (raw_input('Enter grade: '))
f =int (raw_input('Enter grade: '))
g =int (raw_input('Enter grade: '))
h =int (raw_input('Enter grade: '))
cumalitive = a,b,c,d,e,f,g,h
one = a+b+c+d+e+f+g+h
two = one/len(cumalitive)
GPA='defined'
if two<0 or two>100:
GPA<0
if two>=97 and two<=100:
GPA=4.0
elif two>=93 and two<=96:
GPA=4.0
elif two >=90 and two<=92:
GPA=3.7
elif two>=87 and two<=89:
GPA=3.3
elif two>=83 and two<=86:
GPA=3.0
elif two>=80 and two<=82:
GPA=2.7
elif two>=77 and two<=79:
GPA=2.3
elif two>=73 and two<=76:
GPA=2.0
elif two>=70 and two<=72:
GPA=1.7
elif two>=67 and two<=69:
GPA=1.3
elif two>=65 and two<=66:
GPA=1.0
elif two<65 and two>0:
GPA=0.0
if two>0 and two<=100 and GPA>0:
print '\n'
print 'your grade is'
print two
print 'your gpa is: '
print GPA
else:
print '\n'
print 'not valid grades'
it's only able to input 8 grades right now, but i will modify it to keep adding raw_Inputs and since 'two' divides by the length of whatever the length of 'cumalitive' is, then it will be really easy.
This is what for or while loops are for, also just store them in an list. For printing the results the %d might help.
-
Yes i'll try to incorporate a while loop in there, but i haven't had much practice with for loops and what they can do, so i'll research that later. And i also wouldn't know how to use the %d command since all my gpa's variables are already associated with gpas