题库首页 › 青少年软件编程(Python) › 题目 26287

快递系统中,以下Python代码输出结果是?( )class Package: def __init__(self, weight): self.weight = weight def fee(self): return self.weight * 10class Express(Package): def fee(self): return self.weight * 15 + 5p = Package(2)e = Express(2)print(p.fee(), e.fee())

A:20 30
B:20 35
C:30 35
D:20 20

正确答案:B

答案解析

Express 重写了 fee() 方法,普通包裹 2×10=20,加急包裹 2×15+5=35,体现方法重写实现差异化计费。

试卷来源:202609 青少年软件编程等级考试Python六级真题

本卷相关题目

在线做题 同科目题库