Hey, im new to computer programming as well as python, so please be gentle. Im working on a program that will calculate grades. When a value other than A,B,C,D, or F is entered, i want the program to give an error message. This is what i have come up with:
[CODE=python]
print "welcome to the GPA calculator"
totalpoints=0.0
name=raw_input( "please enter the name of the student ")
grade=raw_input ("please enter "+name+ "'s English grade ")
if grade == "A" or "a":
totalpoints = totalpoints + 4.0*3
elif grade == "B "or "b":
totalpoints = totalpoints + 3.0*3
elif grade == "C" or "c":
totalpoints = totalpoints + 2.0*3
elif grade == "D" or "d":
totalpoints = totalpoints + 1.0*3
elif grade == "F" or "f":
totalpoints = totalpoints + 0.0*3
else:
print "Imput is not correct"
[/CODE]
The when a value is entered that is not A...F, the "imput is not correct" does not display. Could somebody please tell me what i am doing wrong here? Thanks alot,
mike
[CODE=python]
print "welcome to the GPA calculator"
totalpoints=0.0
name=raw_input( "please enter the name of the student ")
grade=raw_input ("please enter "+name+ "'s English grade ")
if grade == "A" or "a":
totalpoints = totalpoints + 4.0*3
elif grade == "B "or "b":
totalpoints = totalpoints + 3.0*3
elif grade == "C" or "c":
totalpoints = totalpoints + 2.0*3
elif grade == "D" or "d":
totalpoints = totalpoints + 1.0*3
elif grade == "F" or "f":
totalpoints = totalpoints + 0.0*3
else:
print "Imput is not correct"
[/CODE]
The when a value is entered that is not A...F, the "imput is not correct" does not display. Could somebody please tell me what i am doing wrong here? Thanks alot,
mike
Comment