单选题
适中
#5605
运行以下Python代码,结果是?( ) class Parent ( ) : def __init__ ( self , name ) : self . na…
运行以下Python代码,结果是?( )
答案与解析
正确答案:B
解析
代码中,定义了一个Parent类和一个Child类,Child类继承自Parent类。Child类中的greetings方法使用super()函数调用了父类Parent的方法,并在其基础上添加了额外的逻辑print("Child: Hello!")。