Python hw, functions, class, methods
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/13828661/python-hw-trouble-with-class-and-methods">Python hw, trouble with class and methods</a>  </p>
</blockquote>



<p>I am having trouble with an hw problem in my CS class. The problem has to do with creating a class in python. Heres the prompt:</p>

<p>Your program should contain the following:</p>

<ol>
<li>A function called CreateStudent to do the following:</li>
</ol>

<p>o Ask the user to enter a string, a floating-point number, and an integer (studentʼs name, GPA, and units)</p>

<p>o Print an error message and exit the program if the user did not enter numeric values for the GPA or the units.</p>

<p>o Otherwise, create a Student object with those values. o Return the newly created Student</p>

<ol>
<li>A main function that does the following:</li>
</ol>

<p>o Call Student twice to create two Student object.</p>

<p>o For each of the two students, repeatedly asks the user to enter the
number of units and grade point for the courses the student has taken and updates the Student object each time. It should stop asking about a student when the user enters zero units for that student.</p>

<p>o Using your methods, prints the name of the student with the higher GPA. If the students are tied, you should print both names..</p>

<p><strong>Here is the Student class i created</strong></p>

<pre><code>class Student:
   def __init__(self, name, GPA):
      if units&lt;0:
         units=0
      ifGPA&lt;0:
         GPA=0
      self.name=name
      self.GPA=GPA
      self.units=units
   def update(self,newuits,GPE):
      self.newunits += newunits
      self.GPA=(self.GPA*self.units+GPE)/(self.units)
   def get_name(self):
      return self.name
   def get_GPA(self):
      return self.GPA
</code></pre>

<p><strong>Heres what i have so far</strong></p>

<pre><code>def CreateStudent():
   try:
      student_name=str(input('Student Name?'))
      student_GPA = float(input('GPA?'))
      student_units = int(input('Units?'))
   except ValueError:
      sys.exit('Invalid entry')

   student = Student(student_name, student_GPA, student_units)

   return student

def main():
   student1 = CreateStudent()
   student2 = CreateStudent()
</code></pre>
