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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!