Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

date.pyhttps://www.cse.msu.edu/~cse231/Online/Labs/Lab12/date.py Part B: Class Time You will develop a new data type to model the time on a 24 hour clock, where the three data

image text in transcribed

image text in transcribed

image text in transcribed

date.pyhttps://www.cse.msu.edu/~cse231/Online/Labs/Lab12/date.py

Part B: Class Time You will develop a new data type to model the time on a 24 hour clock, where the three data members represent the hour, the minutes and the seconds. Use the date .py module as a guide. It will be named "class Time and each object of that type will have three instance variables hour mins" and secs"). The module will be named "clock.py 1. Develop the function member (method) named init which will be used to initialize an object of type "Time" when it is created. That function will receive four parameters: a reference to the current object ("self"), the hour, the minutes and the seconds. a. Assume that the last three of the four parameters are integers. b. Use a default value of 0 for those last three parameters. c. Assign those last three parameters to the three instance variables. d. Add a "doc string" to the constructor documenting the purpose of the function. 2. Save the file containing your class as "clock.py", then experiment with your module in the iPython Shell import clock help clock help clock Time A clock Time print (A) 3. Develop the function member named repr which will be used to display the formal representation of an object of type "Time" in the Python shell a. Return a string with the format "Class Time: hh:mm: ss". b. Be sure to place leading zeroes in the string for the hour, minutes and seconds c. Add a "doc string" to the constructor documenting the purpose of the function

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions