Changes

Jump to: navigation, search

OPS435 Python Lab 4

No change in size, 20:57, 11 February 2018
Create a Python Script Demonstrating Comparing Lists
=== Create a Python Script Demonstrating Comparing Lists ===
:'''Perform the Following Instructions'''
::#Create the '''~/ops435/lab4/lab4b.py''' script. The purpose of this script will be to improve the previous script to perform the same joins, matches, and diffs, but this time on lists. ::#Use the following as a template:<source lang="python">
#!/usr/bin/env python3
print('diff: ', diff_lists(list1, list2))
</source>
:::*The match_lists() function should return a list that contains all values found in both lists:::*The diff_lists() function should return a list that contains all values which are not shared between both lists:::*The join_lists() function should return a list that contains all values from both sets:::*All three functions should accept '''two arguments''' both are lists:::*The script should show the exact output as the samples:::*The script should contain no errors::::'''Sample Run 1:'''<source>
run lab4b.py
list1: [1, 2, 3, 4, 5, 6, 7, 8, 9]
</source>
::::'''Sample Run 2 (with import):'''<source>
import lab4b
list1 = [1,2,3,4,5]
list2 = [2,1,0,-1,-2]
print(join_lists(list1,list2)))# Will output [0, 1, 2, 3, 4, 5, -2, -1]print(match_lists(list1,list2) ) # Will output [8, 9, 5, 6, 7]print(diff_lists(list1,list2) ) # Will output [1, 2, 3, 4, 10, 11, 12, 13, 14]
</source>
:::3. Exit the ipython3 shell, download Download the checking script and check your work. Enter the following commands from the bash shell.<source lang="bash">
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
python3 ./CheckLab4.py -f -v lab4b
</source>
:::4. Before proceeding, make certain that you identify any and all errors in lab4b.py. When the checking script tells you everything is OK before proceeding - proceed to the next step.<br><br>
== PART 3 - Dictionaries ==

Navigation menu