Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python A digital clock shows hours ( between 0 and 2 3 ) and minutes ( between 0 and 5 9 ) . Once a

Python A digital clock shows hours (between 0 and 23) and minutes (between 0 and 59). Once a minute, it receives a pulse to advance the time. Complete the Clock class, using instance variables for the hours and minutes. 0 clock.py 1 ## A simulated digital clock. 2 # 3 class Clock: 4 ## Constructs a clock with both the hours and minutes set to 0.5 # 6 definit__(self): 7789 # Advances this clock to the next minute. 10 # 11 def pulse (self): 121314 ## Gets the hours of this clock. 15 # @return the hours (between 0 and 23)16 # 17 def getHours (self): 181920 ## Gets the minutes of this clock. 21 # @return the minutes between 0 and 59)22 # 23 def getMinutes (self): 244 Tester.py 1 from clock import Clock 23 myClock = Clock() for i in range (100) : 5 myClock.pulse)67 print(myClock.getHours)8 print("Expected: 1")9 print (myClock.getMinutes)10 print("Expected: 40")1112 for i in range (70) : 13 myClock.pulse()1415 print (myClock.getHours)16 print("Expected: 2")17 print(myClock.getMinutes())18 print("Expected: 50")1920 for i in range (1270) : 21 myClock pulse)2223 print(myClock.getHours)24 print("Expected: 0")25 print(myClock.getMinutes())26 print("Expected: 0')

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

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions