Changes

Jump to: navigation, search

OPS435 Online Lab4

5 bytes removed, 11:54, 15 October 2020
Create a Python Script for Managing Dictionaries
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
ls CheckLab4.py || wget https://ict.senecacollege.ca/~raymonderic.chanbrauer/ops435/labs/LabCheckScripts/CheckLab4.py
python3 ./CheckLab4.py -f -v lab4a
</source></li>
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
ls CheckLab4.py || wget https://ict.senecacollege.ca/~raymonderic.chanbrauer/ops435/labs/LabCheckScripts/CheckLab4.py
python3 ./CheckLab4.py -f -v lab4b
</source>
:::*The script should contain '''two''' functions:
:::::'''create_dictionary()'''<ol><li>'''accepts''' two lists as arguments keys and values, '''combines''' these lists together to '''create''' a dictionary<br>('''Tip:''' use a for while loop to access elements in both the keys and values lists at the same time)</li><li>'''returns a dictionary''' that has the keys and associated values from the lists</li></ol>
:::::'''shared_values()''' <ol><li>'''accepts''' two dictionaries as arguments and '''finds''' all values that are shared between the two dictionaries<br>('''Tip:''' generate sets containing only values for each dictionary, then use a function mentioned in a previous section to store the values that are common to <u>both</u> lists)</li><li>'''returns a set''' containing '''ONLY values''' found in '''BOTH dictionaries'''</li></ol>
:::*make sure the functions have the correct number of arguments required
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
ls CheckLab4.py || wget https://ict.senecacollege.ca/~raymonderic.chanbrauer/ops435/labs/LabCheckScripts/CheckLab4.py
python3 ./CheckLab4.py -f -v lab4c
</source>
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
ls CheckLab4.py || wget https://ict.senecacollege.ca/~raymonderic.chanbrauer/ops435/labs/LabCheckScripts/CheckLab4.py
python3 ./CheckLab4.py -f -v lab4d
</source>
s1 = 'Seneca'
print(s1, 'contains letter s? ->', 's' in s1))print(s1, 'contains letter S? ->', 'S' in s1))
</source>Did it produce the same result as the find() function in previous python code example?
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
ls CheckLab4.py || wget https://ict.senecacollege.ca/~raymonderic.chanbrauer/ops435/labs/LabCheckScripts/CheckLab4.py
python3 ./CheckLab4.py -f -v lab4e
</source></li>

Navigation menu