以下类的定义错误的是()
A: class Stu: def Aa(self): print("aaaa")
B: class Stu: a=10
C: class Stu: count=10; say(): print("Hello")
D: class Stu: pass
A: class Stu: def Aa(self): print("aaaa")
B: class Stu: a=10
C: class Stu: count=10; say(): print("Hello")
D: class Stu: pass
举一反三
- 以下代码编译后,调用错误的是: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,n="张三"):self.name=ndef show(self):print(self.name)stu=Student("李四")stu.show() A: 张三 B: 李四 C: 张三 李四 D: 李四 张三
- Python中类的定义正确的是 A: class Phone: name = "" call(self, name) print(name, "打电话") B: class Phone: name = "" call(self, name) print(name, "打电话") C: class Phone: name = "" def call(self, name): print(name, "打电话") D: class Phone name = "" def call(self, name): print(name, "打电话")
- 下列程序的输出结果是( )。class Fruit(): def __init__(self): print('Fruit') def grow(self): print('Fruit grow')class Vegetable(): def __init__(self): print('Vegetable') def grow(self): print('Vegetable grow') class Tomato(Fruit,Vegetable): passt = Tomato()t.grow()知识点:多继承 A: FruitFruit grow B: FruitVegetable grow C: VegetableFruit grow D: VegetableVegetable grow
- 如果函数定义为def stu(name): ,则下面对该函数的调用不合法的是( )。 A: stu(“Lucy”) B: stu() C: stu(‘Lucy’) D: stu(name=’Lucy’)