roshan.s at live.com
Fri Dec 11 16:20:13 CET 2009
On Fri, 11 Dec 2009 19:12:32 +0400, Dave Angel <davea at ieee.org> wrote:
> Roshan S wrote:
>> <div class="moz-text-flowed" style="font-family: -moz-fixed">class
>> print"We have a new student "
>> def __init__(self,name='',credit=0,grade=0,quality=0):
>> def inputstudent(self):
>> self.name=raw_input("Enter student Name ")
>> self.credit=input("What da credit hours ")
>> self.grade=input("What da grade ")
>> def quality(self):
>> print"Quality Points: ",self.quality
>> def average(self):
>> print"Grade point average: "+self.grade
>> if gpa == 4: print "Grade: A"
>> elif gpa == 3: print "Grade: B"
>> elif gpa == 2: print "Grade: C"
>> elif gpa == 1: print "Grade: D"
>> def outputstudent(self):
>> "Name: "+self.name
>> #create new student
>> #run teh method
>> We have a new student
>> Enter student Name r
>> What da credit hours 3
>> What da grade 5
>> Traceback (most recent call last):
>> File "C:\Users\Roshan\Desktop\no3.py", line 38, in <module>
>> TypeError: 'int' object is not callable
>> PYTHON version 2.6.3, windows 7
> In your Student class, you're using attribute quality for two very
> different purposes. You have a method by that name, and you have an
> instance variable by that name. You need to call one of them something
> else, probably the instance variable. Don't forget to change all the
> references to it, both in __init__() and in the method quality().
Thanks!!! Problem Solved!
More information about the Tutor