Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are values?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago