举一反三
- 本程序可以直接运行,并得到一个GUI窗口,请选择如下代码注释后面的空格里填入描述这一行所做的事情的顺序。import wxclass MyWindow(wx.App): def OnInit(self): frame = wx.Frame(None,title=Hello world,pos=(0,0)) frame.Show() return True if __name__==__main__: app = MyWindow() app.MainLoop()#____#____#____ #____#____A. 进入这个应用程序的主事件循环B. 继承wxPython应用程序类C. 导入必须的wx模块D. 定义一个应用程序的初始化方法E. 创建一个应用程序类的实例
- 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()
- 中国大学MOOC: 阅读以下代码,四个选项中说法正确的是(____)。class parent: def __init__(self,param): self.v1=paramclass child(parent): def __init__(self,param): parent.__init__(self,param) self.v2=paramodj=child(100)
- class Person: def __init__(self,n="xxx"): self.name=n class Student(Person): def __init__(self,s="male"): self.sex=s def show(self): print(self.name,self.sex) s=Student("female") s.show() 结果:
- class Student: def __init__(self,n="xxx"): self.name=n def show(self): print(self.name) s=Student("yyy") s.show() 结果
内容
- 0
以下有关类的声明,正确的是 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
- 1
下面程序运行的结果是( )。class Person:def __init__(self,n="张三"): self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show() A: 张三 male B: 张三 female C: 出错 D: 张三
- 2
定义类如下: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
- 3
下列程序的输出结果是( )。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
- 4
class Student: def __init__(self,n="xxx"): self.name=n def show(self): print(self.name)s=Student("yyy")s.show()结果 A: yyy B: xxx C: None D: 错误