Python语言程序设计(美-梁勇)第7章习题解答(英文)(共2页).doc

上传人:飞****2 文档编号:14268316 上传时间:2022-05-03 格式:DOC 页数:2 大小:39.50KB
返回 下载 相关 举报
Python语言程序设计(美-梁勇)第7章习题解答(英文)(共2页).doc_第1页
第1页 / 共2页
Python语言程序设计(美-梁勇)第7章习题解答(英文)(共2页).doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《Python语言程序设计(美-梁勇)第7章习题解答(英文)(共2页).doc》由会员分享,可在线阅读,更多相关《Python语言程序设计(美-梁勇)第7章习题解答(英文)(共2页).doc(2页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上Chapter 7 Objects and Classes1.See the section Defining Classes for Objects.2.Define the initializer, create data fields, and define methods.3.Use a constructor4.The name of the initializer is _init_.5.The self refers to the object itself. Through self, the members of the object can be

2、accessed.6.The syntax for constructing an object is ClassName(arguments)The arguments of the constructor match the parameters in the _init_ method without self. The constructor first creates an object in the memory and then invokes the initializer.7.Initializer is a special method that is called whe

3、n creating an object.8. The object member access operator is the dot (.).9.You need to pass an argument in the constructor A() to invoke the class As initializer.10.(a) The constructor should be defined as _init_(self). (b) radius = 3 should be self.radius = 311.count is 100times is 012.count is 0n

4、is 113. _i is a private data field and cannot be accessed from outside of the class.14.Correct. The printout is Welcome.15. _on is a private data field and cannot be accessed outside the class.The way to fix it is to add a getter method for the Boolean property as follows:class A: def _init_(self, o

5、n): self._on = not on def isOn(self): return self._on def main(): a = A(False) print(a.isOn()main() # Call the main function16. Two benefits: (1) for protecting data and (2) for easy to maintain the class.In Python, private data fields are defined with two leading underscores.17. Add two underscores as the prefix for the method name.18. See the text专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁