Open main menu

CDOT Wiki β

Changes

Rchan sandbox

13 bytes removed, 23:24, 2 November 2019
Part 2 - Pure Function and Modifiers
'10:20:00'
</source>
:5 . If you encounter any syntax error or exception, please fix the error before moving on to the next step.:6 . Now try to set seconds to a negative value, i.e. -1800, and then call the change_time() function.
Will it change the time1 object back to '09:50:00'? Let's try it out:<source lang="bash">
>>> format_time(time1)
'10:20:-1800'
</source>
:7. It The result is not correct! So we have to modify and update the change_time() function so that the change_time() function it can handle positive and negative value correctly. After updating the function change_time() has been updatedfunction, test it again in a Python interactive shell with importby importing the new version of the function<source lang='bash'>
[rchan@centos7 wiki_labs]$ python3
Python 3.4.9 (default, Aug 14 2018, 21:28:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> format_time(time1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'format_time' is not defined
>>> from lab7b import *
>>> time1 = Time(9,50,0)
'09:50:00'
</source>
:7. Make sure that you change_time() function works correctly for both positive and negative values of 'seconds'.:8. 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>
:89. 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