I need help please. At first I was understanding the Python language but I got lost somewhere along the line. Can someone please guide me through implementing an addLetterGrade method? I am not very good with computers and I am having a very hard time. This is my first time using a computer language so, please bare with me. I just need someone to help me and maybe answer some of my questions and explain this to me so I can figure out how to do this. Thanks!!
This is what I have so far:
import string import math class Student: def __init__(self, name, hours, qpoints): self.name = name self.hours = float(hours) self.qpoints = float(qpoints) def getName(self): return self.name def getHours(self): return self.hours def getQpoints(self): return self.qpoints def gpa(self): return self.qpoints/self.hours ##I AM STUCK HERE def addLetterGrade(self, Letter, credits): self.hours = credits for ch in Letter: print ord(ch) self.qpoints = credits*Letter if grade_str = "A": grade_str = 4.0 elif grade_str = "B": grade_str = 3.0 elif grade_str = "C": grade_str = 2.0 elif grade_str = "D": grade_str = 1.0 else: grade_str = 0.0 return def main(): print "This program is a modified version of the student class. It adds" print "a mutator method that records a grade and calculates the GPA for" print "the student" print print grade = raw_input("Enter grade for next course, or nothing to finish: ") print credits = input("Enter the number of credit hours for this course: ") stu = Student("stu", 0.0, 0.0) while 1: grade_str = raw_input("Enter grade: ") if grade_str == "": break try: grade = float(grade_str) except ValueError: print "Error, use floating point number" return credits_str = raw_input("Enter credits: ") try: credits = float(credits_str) except ValueError: print "Error, use floating point number" return stu.addGrade(grade, credits) if stu.getHours() == 0.0: print "Zero credit hours recorded" else: print "Final GPA = ", stu.gpa() main()