Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

12 bytes added, 08:14, 3 June 2017
PART 1 - Navigating Items in Lists
:::*The script should have a function called give_first_and_last_item() which returns a list
:::*The script should have a function called give_second_and_third_item() which returns a list
:::3. '''Sample Run 1:'''<source>
run lab3e.py
[100, 200, 300, 'six hundred']
[200, 300]
</source>
:::4. '''Sample Import 1Run 2 (with import):'''<source>
import lab3e
 
lab3e.give_list()
[100, 200, 300, 'six hundred']
 
lab3e.give_first_item()
100
 
lab3e.give_first_and_last_item()
[100, 'six hundred']
 
lab3e.give_second_and_third_item()
[200, 300]
 
</source>
:::53. Exit the ipython3 shell, download the checking script and check your work. Enter the following commands from the bash shell.<source>
cd ~/ops435/lab3/
pwd #confirm that you are in the right directory
python3 ./CheckLab3.py -f -v lab3e
</source>
:::64. Before proceeding, make certain that you identify any and all errors in lab3e.py. When the checking script tells you everything is OK before proceeding to the next step.
::Make notes for all of your observations in your lab log book, and proceed to Part 2.
13,420
edits