Work on this lab with your partner (or on your own if you have not been assigned one).
Unless otherwise indicated, use only the Python operations and commands we have described thus far in class.
Show your work for a given problem to the instructor or one of the lab assistants before moving on to the next problem, but do not get too bogged down on any one problem.
In the common case, you will not complete the exercises during our scheduled lab. It is then up to you to complete the lab on your own time (as part of the corresponding programming assignment).
Email me a copy of your work (attach the lab4.py
)
file by replying to the email that officially announces the lab. If
working with a lab partner send me just one copy for the pair, but CC
your partner.
Download and unzip the starter archive.
Use IDLE to open lab4_examples.py
in the
lab4
folder. (Re)read the functions defined in that file
and experiment with using them.
Use IDLE to open lab4.py
in the lab4
folder.
Remove the starter comment line in that file.
Replace <YOUR NAME(s) GO HERE>
with your
name(s).
Save as you go.
Run the module in IDLE, test your functions in the IDLE shell.
Included in the lab4
folder is a runnable solution
module called lab4x.py
. You can use it to see the result of
executing the solution version of any of the assigned exercises. After
running either lab4_examples.py
or lab4.py
as
a module in IDLE, you can import lab4x
and access the
solution versions in the IDLE shell as follows:
>>> import lab4x
>>> lab4x.remove('iconic', 1)
'ionic'
If one of the exercises you are working on requires the solution
to a previous exercise that you have not yet completed, you can
(temorarily) use the solution version. Example: suppose you are given
the task of using the remove
function to remove the second
to last item in a string. If you do not yet have your version of
remove
working correctly, you can use the
lab4x
version by adding to the top of your
lab4.py
file:
import lab4x
and then, write code like:
def remove_penultimate(s):
t = lab4x.remove(s, len(s) - 2)
return t