中国大学MOOC: Student是一个学生类,其构造函数的声明为def __init__(self, name, score),对Student类进行实例化生成对象stu1,正确的是
举一反三
- Student是一个学生类,其构造函数的声明为def __init__(self, name, score),对Student类进行实例化生成对象stu1,正确的是 A: stu1 = Student('xiaoming',89) B: stu1 = Student(stu1,'xiaoming',89) C: xiaoming = Student(stu1,89) D: stu1 = Student(89,'xiaoming')
- 以下有关类的声明,正确的是 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 (1)(self):print(self.name)if __name__=='__main__':stu1=Student('Li Xiaoming')stu2=Student('Ma Hong')stu3=(2)del stu2del stu1完成(1)和(2)代码填写,使之输出如下结果:Li XiaomingMa Hong
- 以下代码中,实例方法定义正确的是() 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
- 以下代码编译后,调用错误的是: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__();