obj.name() 对象不可调用
obj.name() object is not callable
#polymorphism
class father:
def __init__(self,firstname,lastname,age):
self.name=firstname
self.secoundname=lastname
self.age=age
def name(self):
print("name"+self.name+"secoundname"+self.secoundname)
def age(self):
print("age"+str(self.age))
class son(father):
def name(self):
print("name"+self.name+"secoundname"+self.secoundname)
class daughter(father):
def name(self):
print("name"+self.name+"secoundname"+self.secoundname)
obj=father("k","a",23)
obj1=son("A","f",2)
obj2=daughter("f","y",6)
obj.name()
obj.age()
obj1.name()
obj1.age()
obj2.name()
obj2.age()
> Blockquote
**giving an error
Blockquote
obj.name()
'str' object is not callable
what have been wrong in the above its just some silly mistake maybe it
is a code with function class and objects does the object defined is
incorrrect or what is the problem not able to make out can someone
help me**
学习缩进
a = int (input("x"))
b = int (input ("y"))
c = int (input("z "))
if a ==b==c:
print ("all equal")
elif(a>b and a>c):
print("x is greatest")
elif(b>c and b>a):
print("y is greatest ")
else :
print("z is greatest")
#polymorphism
class father:
def __init__(self,firstname,lastname,age):
self.name=firstname
self.secoundname=lastname
self.age=age
def name(self):
print("name"+self.name+"secoundname"+self.secoundname)
def age(self):
print("age"+str(self.age))
class son(father):
def name(self):
print("name"+self.name+"secoundname"+self.secoundname)
class daughter(father):
def name(self):
print("name"+self.name+"secoundname"+self.secoundname)
obj=father("k","a",23)
obj1=son("A","f",2)
obj2=daughter("f","y",6)
obj.name()
obj.age()
obj1.name()
obj1.age()
obj2.name()
obj2.age()
> Blockquote
**giving an error
Blockquote obj.name() 'str' object is not callable what have been wrong in the above its just some silly mistake maybe it is a code with function class and objects does the object defined is incorrrect or what is the problem not able to make out can someone help me**
学习缩进
a = int (input("x"))
b = int (input ("y"))
c = int (input("z "))
if a ==b==c:
print ("all equal")
elif(a>b and a>c):
print("x is greatest")
elif(b>c and b>a):
print("y is greatest ")
else :
print("z is greatest")