题库 Python题库 题目列表 有Python程序段如下,下列选项错误的是?( )class&n...
单选题

Python程序段如下,下列选项错误的是?( )

class Cat():       
    def __init__(self,name,color):
        self.name=name
        self.color=color
    def sit(self):  
        print(self.color +self.name+"is sitting.")
A.

A.使用class关键字来定义一个Cat类,类名的首字母必须要大写

B.

方法__init()__定义了三个参数:selfnamecolor,其中self参数可省略

C.

语句self.color=color”获取存储在参数color中的值并存储到self的属性color

D.

Cat类还定义了一个方法sit()

题目信息
2025年 3月 选择题
-
正确率
0
评论
2
点击