python程序设计第七章答案_Python语言程序设计(美-梁勇)第7章习题解答(英文)

Chapter 7 Objects and Classes

1.

See the section "Defining Classes for Objects."

2.

Define the initializer, create data fields, and define

methods.

3.

Use a constructor

4.

The name of the initializer is __init__.

5.

The self refers to the object itself. Through self, the

members of the object can be 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 when

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 A

’s

initializer.

10.(a) The constructor should be defined as __init__(self).

(b) radius = 3 should be self.radius = 3

11.

count is 100

times is 0

12.

count is 0

n is 1

13.

_

_i is a private data field and cannot be accessed from

outside of the class.

14.

Correct. The printout is Welcome.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值