Question: So far, we can create a new Clock object, but we can't do anything with it . Next, we need to define additional operations that
So far, we can create a new Clock object, but we can't do anything with it Next, we need to define additional operations that can be performed on our Clock objects. We added three methods that can be used to extract the individual components of the data contained in the object, and three methods to adjust or shift the seconds stored in the objects.
class Clock:
def initself hr min, sec:
self.hours hr
self.minutes min
self.seconds sec
def gethoursself:
return self.hours
def getminutesself:
return self.minutes
def getsecondsself:
return self.seconds
def shiftsecondsself sec:
if sec and self.seconds sec :
self.seconds sec
return self.seconds
return 'Unsuccessful operation'
We can use the new methods to extract and print the values of one of the objects we just created:
hrsA clockA.gethours
minA clockA.getminutes
clockB.shiftseconds
display f'Clock time is hrsA hours and minA minutes
display
'Clock time is hours and minutes
Which of the following retrieves the seconds from clockB?
Group of answer choices
clockB.getseconds
clockA.getsecondsclockB
clockB.getsecondsself
Clock.getseconds
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
