Question
Fix the coding erros: class Timer: def __init__(self, h, m): 'initialize the timer according to the hours and minutes passed as parameters' self.hours = h
Fix the coding erros:
class Timer: def __init__(self, h, m): 'initialize the timer according to the hours and minutes passed as parameters' self.hours = h self.minutes = m
def tick( ): 'decrement the timer by one minute' if self.minutes == 0: self.minutes = 59 self.hours -= 1 else: self.minutes -= 1
def zero(self): 'return True if the timer has reached 0:00' self.hours == 0 and self.minutes == 0 def __str__(self): return '{}:{:02d}'.format(h, m)
t = Timer(1,0)
# should print 1:00 print(t)
t.tick()
# should print 0:59 print(t)
for i in range(55): t.tick()
# should print 0:04 print(t)
# This loop should print # 0:03 # 0:02 # 0:01 # 0:00 while not t.zero(): t.tick() print(t)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started