python programming

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

python programming

Post by answerhappygod »

python programming
Python Programming 1
Python Programming 1 (50.72 KiB) Viewed 42 times
Below is the TV class we covered in the class. Please make changes/additions to the code. Note that you are only asked to provide the modified initializer and the additional methods. 1. Change all data fields to private. Please only provide the modified initializer. (5 pts) 2. Add an instance method named setStatus.setStatus method sets the instance to status by taking information of channel, volumneLevel, and on as arguments. Please make sure that the channel and volumnLevel validity check, as in the code below, should be maintained. (10 pts) 3. Add an instance method named getStatus, that returns all data fields as an instance's status. (5 pts) class TV: definit__(self): self.channel = 1 # Default channel is 1 self.volumeLevel = 1 # Default volume level is 1 self.on False # By default TV is off def turnOn(self): self.on True def turnOff(self): self.on False def getChannel(self): return self.channel def setChannel(self, channel): if self.on and 1 <= self.channel <= 120: self.channel channel.
def getVolume Level(self): return self.volume Level def setVolume (self, volumeLevel): if self.on and \ 1 <= self.volume Level <= 7: self.volumeLevel = volumeLevel def channelUp (self): if self.on and self.channel < 120: self.channel += 1 def channelDown (self): if self.on and self.channel > 1: self.channel - 1 def volumeUp (self): if self.on and self.volumeLevel < 7: self.volumeLevel += 1 def volume Down (self): if self.on and self.volumeLevel > 1: self.volume Level = 1
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply