Changes

Jump to: navigation, search

Rchan sandbox

688 bytes added, 00:27, 3 November 2019
Part 2 - Pure Function and Modifiers
'10:20:-1800'
</source>
:7. The result is not correct! So we have to modify and update the change_time() function so that it can handle positive and negative value correctly. The following step is necessary:::(a) We must first add code to check on the '''second''' attribute of the time object to make sure that it is not less than zero. If it is, we must borrow one from the '''minute''' attribute and add 60 to the '''second''' attribute. We have to repeat this checking until the '''second''' attribute is no long less than zero. ::(b) We then have to add code to check on the '''minute''' attribute. If it is less than zero, we must borrow 1 from the 'hour' attribute and add 60 to the '''minute''' attribute. We have to repeat this checking until the '''minute''' attribute is no long less than zero.:8. After updating the change_time() functionwith the above additional code, save the file and test it again in a Python interactive shell by importing the new version of the function.<source lang='bash'>
[rchan@centos7 lab7]$ python3
Python 3.4.9 (default, Aug 14 2018, 21:28:57)
'09:50:00'
</source>
:79. Make sure that you change_time() function works correctly for both positive and negative values of 'seconds'.:810. Download the checking script and check your work. Enter the following commands from the bash shell.<source lang="bash">
cd ~/ops435/lab7/
pwd #confirm that you are in the right directory
python3 ./CheckLab7.py -f -v lab7b
</source>
:910. Before proceeding, make certain that you identify all errors in lab7b.py. When the checking script tells you everything is OK - proceed to the next step.
<br><br>
1,760
edits

Navigation menu