电视类问题

sp085504 程序题 共 个子题

题目说明

class TV:
    def         ①        (self, brand, model, size, price):
        self.brand = brand  #品牌
        self.model = model  #型号
        self.size =        ②          #尺寸
        self.price = price  #价格
        self.power = False
        self.volume = 50   #体积
        self.channel = 1
    def power_on(self):
        self.power = True
    def power_off(self):
        self.power = False
    def adjust_volume(self, volume): #调整体积大小
        self.volume = volume
    def switch_channel(self, channel):  #切换频道
        self.channel = channel
class SmartTV(TV):
    def __init__(self, brand, model, size, price):
        super().__init__(brand, model, size, price)
        self.internet = False
    def connect_internet(self):  #开启联网
        self.internet = True
    def disconnect_internet(self):#关闭联网
                 ③
    def watch_online(self, url):  #是否能看网络资源
        if         ④        :#判断是否联网
            print("正在观看:", url)
        else:
            print("请先连接网络")
# 创建普通电视和智能电视实例
tv1 = TV("创维", "LCD", 55, 3999)
tv2 =         ⑤        ("小米", "OLED", 65, 4999)

# 测试普通电视的属性和方法
tv1.power_on()
tv1.adjust_volume(60)
tv1.switch_channel(3)
print("电视品牌:{},电视型号:{},电视尺寸:{}英寸,电视价格:{}元,电视状态:{},音量:{},频道:{}".format(tv1.brand, tv1.model, tv1.size, tv1.price, tv1.power, tv1.volume, tv1.channel))

# 测试智能电视的属性和方法
tv2.power_on()
tv2.adjust_volume(70)
tv2.switch_channel(5)
tv2.connect_internet()
tv2.watch_online("https://www.cctv.com")
print("电视品牌:{},电视型号:{},电视尺寸:{}英寸,电视价格:{}元,电视状态:{},音量:{},频道:{},是否连接网络:{}".format(tv2.brand, tv2.model, tv2.size, tv2.price, tv2.power, tv2.volume, tv2.channel, tv2.internet))

本题为编程题,提交代码并运行通过测试点后判分。

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
提交记录
共 条 仅展示自由练习提交
正在加载提交记录…
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧