以下代码中,实例方法定义正确的是() A: class Student: def setName(self,name): self.name=name B: class Student: def setName(name): self.name=name C: class Student: def setName(self): self.name=name D: class Student: def setName(name,self): self.name=name
以下代码中,实例方法定义正确的是() A: class Student: def setName(self,name): self.name=name B: class Student: def setName(name): self.name=name C: class Student: def setName(self): self.name=name D: class Student: def setName(name,self): self.name=name
以下有关类的声明,正确的是 A: class Student(object) def __init__(self, name, score): self.name = name self.score = score B: class Student(object) def __init__(self, name, score) self.name = name self.score = score C: class Student(object): def __init__(self, name, score): self.name = name self.score = score D: class Student(object): def __int__(self, name, score): self.name = name self.score = score
以下有关类的声明,正确的是 A: class Student(object) def __init__(self, name, score): self.name = name self.score = score B: class Student(object) def __init__(self, name, score) self.name = name self.score = score C: class Student(object): def __init__(self, name, score): self.name = name self.score = score D: class Student(object): def __int__(self, name, score): self.name = name self.score = score
{class Student:def __init__(self, name):self.name = namedef out(self):print('name:', self.name)终端应如何输入(创建实例)______、(调用方法)______,使其可以输出“name:王芳”}
{class Student:def __init__(self, name):self.name = namedef out(self):print('name:', self.name)终端应如何输入(创建实例)______、(调用方法)______,使其可以输出“name:王芳”}
class Student:def __init__(self,name,age):self.name=nameself.age=agedef fun1(self):print("hello")( )def fun2(self):print("yes")child=Child("Tom",20)child.fun1()
class Student:def __init__(self,name,age):self.name=nameself.age=agedef fun1(self):print("hello")( )def fun2(self):print("yes")child=Child("Tom",20)child.fun1()
定义类如下:class Hello(): def __init__(self,name): self.name=name def showInfo(self): print(self.name)下面代码能正常执行的 ( )。 A: h = Helloh.showInfo() B: h = Hello()h.showInfo('张三') C: h = Hello('张三')h.showInfo() D: h = Hello('admin')h.showInfo
定义类如下:class Hello(): def __init__(self,name): self.name=name def showInfo(self): print(self.name)下面代码能正常执行的 ( )。 A: h = Helloh.showInfo() B: h = Hello()h.showInfo('张三') C: h = Hello('张三')h.showInfo() D: h = Hello('admin')h.showInfo
写出输出结果:class Student: def __init__( self, name,age=18): self.name=name self.age=agestudent=Student("李强",21)print(student.age)
写出输出结果:class Student: def __init__( self, name,age=18): self.name=name self.age=agestudent=Student("李强",21)print(student.age)
请执行以下代码,说明错误出现的行数。1. class Dog(object):2. def __init__(self,name):3. self.name = name4. @property5. def eat(self):6. print(" %s is eating" %self.name)7. 8. d = Dog("wangwang")9. d.eat()知识点:属性的定义和使用
请执行以下代码,说明错误出现的行数。1. class Dog(object):2. def __init__(self,name):3. self.name = name4. @property5. def eat(self):6. print(" %s is eating" %self.name)7. 8. d = Dog("wangwang")9. d.eat()知识点:属性的定义和使用
以下代码编译后,调用错误的是:class Student: def __init__(self,name,age): self.name=name self.age=age def __del__(self): del self.name del self.age print("对象数据删除完毕!")stu=Student("zs",10) A: stu.name; B: stu.__init__("李四",20); C: del stu; D: stu.__del__();
以下代码编译后,调用错误的是:class Student: def __init__(self,name,age): self.name=name self.age=age def __del__(self): del self.name del self.age print("对象数据删除完毕!")stu=Student("zs",10) A: stu.name; B: stu.__init__("李四",20); C: del stu; D: stu.__del__();
定义类的代码如下:class Person():def __init__(self,name):self.name=namedef show(self):print(self.name) A: p=Personp.show() B: p=Person()p.show('李思') C: p=Person('李思')p.show() D: p=Person('李思')show()
定义类的代码如下:class Person():def __init__(self,name):self.name=namedef show(self):print(self.name) A: p=Personp.show() B: p=Person()p.show('李思') C: p=Person('李思')p.show() D: p=Person('李思')show()
下面程序的输出结果是( )。class Student: count = 0 def __init__(self, name): self.name = name Student.count += 1s1 = Student("Alex")s2 = Student("Jack")print(s1.count)
下面程序的输出结果是( )。class Student: count = 0 def __init__(self, name): self.name = name Student.count += 1s1 = Student("Alex")s2 = Student("Jack")print(s1.count)