1,760
edits
Changes
→Part 1 - Simple Object Class with external functions
:'''Perform the following steps:'''
:1. Download or create the above Pythone script '''lab7a.py''' in your ~/ops435/lab7 directory.
:2. Create a new Python script named '''lab7a1.py''' in the lab7 directory:<source lang="bash">
cd ~/ops435/lab7
vi ~/ops435/lab7/lab7a1.py
09:50:00 + 00:50:00 --> 09:100:00
</source>
:5 . If you pay a little bit attention on the outputs, you should notice that the sum_times() function did not carry 60 minutes over to hour. It also will not carry 60 seconds over to minute.:6 . To fix that problem, perform the following:
::(a) Edit the file '''lab7a.py''' and modify the function sum_times(). Add code to check the values of the time object's three attributes. If the value of the minute attribute is more than 60, carry it over to the hour until it is less than 60. Do the same for the value of the second attribute.
::(b) The illustration below indicates where you should perform the carry over operation in the sum_times() function in '''lab7a.py''':<source lang="python">