# Changes

## OPS435 Python Lab 4

, 5 June
Create a Python Script Demonstrating Comparing Lists
=== PYTHON REFERENCE ===
:As you develop your Python scripting skills, you may start to be "overwhelmed" with the volume of information that you have absorbed over these labs. One way to help, is to learn to use online references effectively in order to obtain information regarding Python scripting techniques and tools.
:Below is a table with links to useful online Python reference sites (by category). You may find these references useful when performing assignments, etc.
=== Create a Python Script Demonstrating Comparing Sets ===
:'''Perform the Following Instructions'''
::#Create the '''~/ops435/lab4/lab4a.py''' script. The purpose of this script will be to demonstrate the different way of comparing sets. There will be three functions, each returning a different set comparison. ::#Use the following template to get started:<source lang="python">
#!/usr/bin/env python3
</source>
:::*The join_sets() function should return a set that contains all values from both sets:::*The match_sets() function should return a set that contains all values found in both sets:::*The diff_sets() function should return a set that contains all values which are not shared between both sets:::*All three functions should accept '''two arguments''' both are sets:::*The script should show the exact output as the samples:::*The script should contain no errors
::::'''Sample Run 1:'''<source>
./lab4a.py
set1: {1, 2, 3, 4, 5, 6, 7, 8, 9}
diff: {1, 2, 3, 4, 10, 11, 12, 13, 14}
</source>
::::'''Sample Run 2 (with import):'''<source>
import lab4a
set1 = {1,2,3,4,5}
# Will output {-2, -1, 0, 3, 4, 5}
</source>
<ol><li value='3' style="margin-left:40px25px;">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 lab4a
</source></li>
<li style="margin-left:40px25px;">Before proceeding, make certain that you identify all errors in lab4a.py. When the checking script tells you everything is OK - proceed to the next step.</li></ol>
=== 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
def join_lists(l1, l2):
# join_lists will return a list that contains every value from both l1 and l2 inside it
def match_lists(l1, l2):
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 setslists:::*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]
list2: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
join: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
match: [8, 9, 5, 6, 7, 8, 9]
diff: [1, 2, 3, 4, 10, 11, 12, 13, 14]
</source>
::::'''Sample Run 2 (with import)under interactive python shell:'''<source>
import lab4b
list1 = [1,2,3,4,5]
list2 = [2,1,0,-1,-2]
print(lab4b.join_lists(list1,list2)))# Will output [0, 1, 2, 3, 4, 5, -2, -1]print(lab4b.match_lists(list1,list2) ) # Will output [81, 9, 5, 6, 72]print(lab4b.diff_lists(list1,list2) ) # Will output [1, 20, 3, 4, 105, 11-2, 12, 13, 14-1]
</source>
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 ==
::By now, you have probably been exposed to database terminology. For example, a '''database''' is a collection of ''related records''. In turn, '''records''' are a collection of ''related fields''. In order to access a record in a database, you would need to access it by '''key field(s)'''. In order words, those key field(s) are a '''key that unlocks the access to a record''' within a database. ::In Python, a '''dictionary''' is a set of key-value pairs. Dictionaries are '''unordered''', like sets, however any value can be retrieved from a dictionary if you know the key. This section will go over how to create, access, and change dictionaries, providing giving you a new powerful tool to store and manipulate data.
::'''Perform the Following Steps:'''
::#Launch the ipython3 shell:<source>ipython3</source>::#Let's begin by creating a new dictionary (for practice)in a temporary Python file:<source lang="python">
dict_york = {'Address': '70 The Pond Rd', 'City': 'Toronto', 'Postal Code': 'M3J3M6'}
</source>You should note that the syntax to define a dictionary is similar to defining sets (i.e. using '''{}''').<br>Unlike , but unlike sets, dictionaries use '''<code>key:value</code>''' pairs within the dictionary, each ''key:value'' pair in turn, are is separated by commas.<br><br>You can get help associated with your dictionary by using functions such as '''dir()''' and '''help()'''.<br><br>::#Issue All the following and note all the available functions available and how to obtain assistance with values in a dictionary objects:<source lang="python">dir(dict_york)help(dict_york)</source>All values can be viewed retrieved by using the '''dictionary.values()''' function. This particular function provides a '''list''' containing all values.<br><br>::#To demonstrate, issue the following:<source lang="python">helpprint(dict_york.values()dict_york.values()</source>All keys to access the ''key:pair'' values within a dictionary can be viewed by retrieved using the '''dictionary.keys()''' function. This function provides a '''list''' containing all keys<br><br>::#To demonstrate this, issue the following:<source lang="python">help(dict_york.keys)
dict_york.keys()
</source>Armed with this information, We can retrieve <u>individual</u> values from a dictionary by provide providing the key associated with the key:pair value<br><br>::#For example, issue the following:<source lang="python">print(dict_york['Address'])print(dict_york['Postal Code'])
</source>
::#Dictionary keys can be any '''immutable''' values (i.e. not permitted for value to be changed). Types of values include: '''strings''', '''numbers''', and '''tuples'''. Trying ::#Try adding a couple new keys key and values value to the dictionary by issuing:<source lang="python">
print(dict_york)print(dict_york.values())print(dict_york.keys())
</source>
::#Let's add another key:value pair to our dictionary to change the province key:pair value to BC:<source lang="python">
dict_york['Province'] = 'BC'
print(dict_york)print(dict_york.values())print(dict_york.keys())</source>'''WARNING: Dictionary keys must be unique'''. Attempting to add a key that already exists in the dictionary will <u>overwrite</u> the existing value for that key!<br><br>::#To demonstrate, issue the followingFor example:<source lang="python">
dict_york['Province'] = 'ON'
print(dict_york)print(dict_york.values())print(dict_york.keys())</source>You should notice that key value for the 'Province' key has been changed back to 'ON'.<br><br>These The lists that contain the values and keys of the dictionary are not <u>real</u> python lists - they are "views of the dictionary" and therefore are <u>immutable</u>. You could change these views into usable lists by using the '''list()''' function (where the index can be used to access individual values).<br><br>::#For example, issue the following:<source lang="python">
list_of_keys = list(dict_york.keys())
print(list_of_keys[0]</source>::#In addition, lists can be changed into sets if we would like to perform comparisons with another set. To demonstrate, issue the following:<source lang="python">set_of_keys = set(dict_york.keys())set_of_values = set(dict_york.values())set_of_keys | set_of_values
</source>
::#Lists can be used with '''for loops'''. To Demonstrate, issue the following:<source lang="python">
list_of_keys = list(dict_york.keys())
for key in list_of_keys:
print(key)
for value in dict_york.values():
print(value)
</source>Additional Information regarding Dictionaries:<ul><li>The values and keys can be looped over using the index as well
::#The '''range()''' function provides a list of numbers in a range.</li><li>The '''len()''' function provides a the number of items in a list.</li><li>Used together '''len()''' and '''range()''' can be used to create a list of usable indexes for a specific list</li></ul><br>Let's create a dictionary by using lists in order to store our dictionary data. First, we need to pair the keys and values of two separate lists.<br><br>
::#Issue the following:<source lang="python">
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
list_of_indexes = range(0, len(dict_york.keys()))
list_of_indexes
list_of_keys[0]
list_of_values[0]
</source>Now, let's use these '''newly-created lists''', '''len()''' &amp; '''range()''' functions with a '''for loop''' to construct our dictionary:<br><br>
::#Issue the following:<source lang="python">
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
for index in range(0, len(list_of_keys)):
print(list_of_keys[index] + '--->' + list_of_values[index])
</source>
::#Looping using indexes is not the best way to loop through a dictionary. A new dictionary could be created using this method, but this is '''not good''':<source lang="python">
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
new_dictionary = {}
for index in range(0, len(list_of_keys)):
new_dictionary[list_of_keys[index]] = list_of_values[index]
</source>
::#The above method uses a lot of memory and loops. The best method to create a dictionary from two lists is to use the zip() function:<source lang="python">
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
new_dictionary = dict(zip(list_of_keys, list_of_values))
</source>
::#Looping through the keys in a dictionary also provides a easy way to get the value for each key at the same time:<source lang="python">
for key in dict_york.keys():
print(key + '--->' + dict_york[key])
</source>
::#An alternative (possibly more efficient) method would be to cause both the key and its value to be extracted into a single (using a for loop, and using a special object):<source lang="python">
for key, value in dict_york.items():
print(key + ' | ' + value)
</source>

=== Create a Python Script for Managing Dictionaries ===
:'''Perform the Following Instructions'''
# Place code here - refer to function specifics in section below
def split_dictionary(dictionary):
# Place code here - refer to function specifics in section below
def shared_values(dict1, dict2):
# Place code here - refer to function specifics in section below
york = create_dictionary(list_keys, list_values)
print('York: ', york)
keys, values = split_dictionary(dict_newnham)
print('Newnham Keys: ', keys)
print('Newnham Values: ', values)
keys, values = split_dictionary(york)
print('York Keys: ', keys)
print('York Values: ', values)
common = shared_values(dict_york, dict_newnham)
print('Shared Values', common)
</source>
:::*The script should contain '''threetwo''' functions::::::'''create_dictionary()'''<ol><li>'''accepts''' two lists as arguments keys and values, '''combines''' these lists together to '''create''' a dictionary</li><libr>('''returns a dictionaryTip:''' that has use a while loop to access elements in both the keys and associated values from lists at the listssame time)</li></ol>:::::'''split_dictionary()'''<ol><li>'''accepts''' returns a single dictionary as a argument and '''splits''' that has the dictionary into two lists, keys and associated values</li><li>'''returns two lists''': The return function can return multiple from the lists (separated by a comma). In our case, use: '''return keys, values'''</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
:::*The script should contain no errors
::::'''Sample Run 1:'''<source>
run ./lab4c.py
York: {'Country': 'Canada', 'Postal Code': 'M3J3M6', 'Address': '70 The Pond Rd', 'Province': 'ON', 'City': 'Toronto'}
Newnham Keys: ['Country', 'Postal Code', 'Address', 'Province', 'City']
Newnham Values: ['Canada', 'M2J2X5', '1750 Finch Ave E', 'ON', 'Toronto']
York Keys: ['Country', 'Postal Code', 'Address', 'Province', 'City']
York Values: ['Canada', 'M3J3M6', '70 The Pond Rd', 'ON', 'Toronto']
</source>
::::'''Sample Run 2(with import):'''<source>
import lab4c
dict_york = {'Address': '70 The Pond Rd', 'City': 'Toronto', 'Country': 'Canada', 'Postal Code': 'M3J3M6', 'Province': 'ON'}
list_values = ['70 The Pond Rd', 'Toronto', 'Canada', 'M3J3M6', 'ON']
york = lab4c.create_dictionary(list_keys, list_values) york{'Address': '70 The Pond Rd', 'City': 'Toronto', 'Country': 'Canada', 'Postal Code': 'M3J3M6', 'Province': 'ON'} keys, values = split_dictionary(dict_newnham) keys['Country', 'Postal Code', 'Address', 'Province', 'City'] values['Canada', 'M2J2X5', '1750 Finch Ave E', 'ON', 'Toronto'] keys, values = split_dictionary(york) keys['Country', 'Postal Code', 'Address', 'Province', 'City']
valuesprint(york)[# Will print: {'CanadaAddress': '70 The Pond Rd', 'M3J3M6City': 'Toronto', 'Country': '70 The Pond RdCanada', 'Postal Code'ON: 'M3J3M6', 'TorontoProvince': 'ON']}
common = lab4c.shared_values(dict_york, dict_newnham)
print(common)# Will print: {'Canada', 'ON', 'Toronto'}
</source>
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
python3 ./CheckLab4.py -f -v lab4c
</source>
:::4. Before proceeding, make certain that you identify any and all errors in lab4c.py. When the checking script tells you everything is OK before proceeding proceed to the next step.<br><br> <!--== PART 4 - List Comprehension == '''SKIP THIS PART''' :We have already have had an introduction to lists. We will now explore advanced functions that use and generate lists. This is a very common practice in Python: understanding how to generate, manipulate, and apply functions to items inside a list can be incredibly useful. List comprehension is a way to build new lists from existing list and to do it faster than simply looping over lists. :'''Perform the Following Steps''' :#Let's start by creating a list and then applying some functions to each item in that list. Issue the following to create a list and then display the square for each item within that list:<source>l1 = [1, 2, 3, 4, 5]for item in l1: print(item ** 2)</source>In order to store these results (i.e. squares) for later use, you would have to create a new list and append the squares to it. This will generate a new list that contains squared values in the same positions of the first list. In this way, you are using an existing list in order to create a new (larger) list.<br><br>:#To demonstrate, issue the following:<source>l1 = [1, 2, 3, 4, 5]l2 = []for item in l1: l2.append(item ** 2)l1l2</source>Since this may be a repetitive task, it makes more sense to create a function that will append the squares to a new item within an existing list.<br><br> :#Issue the following to see how that can be performed:<source>def square(number): return number ** 2 l1 = [1, 2, 3, 4, 5]l2 = []for item in l1: l2.append(square(item)) l1l2</source>The '''map()''' function can be used to apply a function on each item in a list. This is exactly what happened in the previous example; however, using the ''map()'' function provides for better syntax, and removes the loop (including the variable that was created inside the loop). Therefore, using the ''map()'' function will make your Python script more efficient while performing the same task.<br><br>:#To demonstrate, issue the following:<source>def square(number): return number ** 2 l1 = [1,2,3,4,5]l2 = list(map(square, l1)) l1l2</source>The above ''map()'' function requires another function as well as a list. This means that before using (calling) the map() function, that other function would have to have been defined earlier in the script. This entire process can be avoided through the use of '''anonymous functions'''. This is the ability to create a simple function without defining it, and pass it on to other function calls. You will use the the '''lambda anonymous function''', which will return a function that you can use in that function immediately (i.e. without having to declare it in your script). The function takes 1 argument (called: x), and it will square that value.<br><br>:#To demonstrate, issue the following:<source>square = lambda x: x ** 2l1 = [1,2,3,4,5]l2 = list(map(square, l1)) l1l2</source>:#The above code is actually not particularly good, the whole purpose of using lambda here is we were avoiding the function definition and just quickly returning a function. However this does break down exactly what lambda does, it returns a function for use. Fix this by removing the square function and just use the return function from lambda. Now remember what map requires? map's first argument is a function, and map's second argument is a list. Here lambda will return a function and provide it as the first argument.<source>l1 = [1,2,3,4,5]l2 = list(map(lambda x: x ** 2, l1)) l1l2</source>:#Using the list comprehensions above our code will be faster and more efficient than using multiple variables and loops.-->
= INVESTIGATION 2: STRINGS =
:Strings are basically a list of characters (bits of text). Strings store text so that they can be later for manipulation (by a wide range of functions). This section will investigate strings in more detail such as '''cutting strings into sub-strings''', '''joining strings''', '''formatting strings''', '''searching through strings''', and '''matching strings against patterns'''.<br><br>Strings are '''immutable''' data objects - this means that once a string is created, it <u>cannot</u> be modified. In order to make a change inside a string, you would first make a copy of the part of the string (i.e. sub-string) for manipulation.
== PART 1 - Strings and Substrings ==
:'''Perform the Following Steps:'''
:#Launch the ipython3 shell<source>ipython3</source>:#Issue the following to create Create some stringsin a temporary Python file:<sourcelang="python">
course_name = 'Open System Automation'
course_code = 'OPS435'
course_number = '435'</source>Strings can contain any '''characters''' inside them, whether they are '''letters''', '''numbers''', or '''symbols'''. In our ipython3 shell the values inside each string variable can be seen just by typing the string variable name. However, when writing python scripts, these string variables should be placed inside '''print()''' functions in order to display on the screen.<br><br> :#Strings can also be '''concatenated''' (i.e. "combined together") by using the '''+''' sign, just make sure string are only concatenating other strings with strings(no lists, no numbers, no dictionaries, etc.).<br><br>:#To demonstrate what was previously mentioned, issue the following:<sourcelang="python">course_namecourse_codecourse_number
print(course_name)
print(course_code)
print(str(course_number))
print(course_name + ' ' + course_code + ' ' + str(course_number))
</source>Strings can also use special syntax for string '''repetition''' by <u>multiplying</u> the string by a number. This will repeat that string that many times. Repetition with '''*''' is useful whenever a string needs to be repeated more than once<br><br>:#Issue the following:<source>print(course_name + '-' + course_code)print(course_name + '-'*5 + course_code)print(course_name + '-'*25 + course_code)print('abc'*2)print(course_code*5)</source>When using the '''print()''' function, you can display '''special characters'''. One such special character is the is the newline character (denoted by the symbol: '''\n'''). This allows you to separate content between new lines or empty lines.<br><br>:#To demonstrate, issue the following:<sourcelang="python">
print('Line 1\nLine 2\nLine 3\n')
</source>
:#By using both Strings have many built-in functions that we can use to manipulate text. [https://docs.python.org/3/library/stdtypes.html#string repetition and -methods Here's a newline character, multiple lines can be created at oncelist]. Issue the following:#Lets try out several different functions:<sourcelang="python">print('Line 1' + '\n'*4 + 'Line 5\nLine 6'course_name.lower()) # Returns a string in lower-case lettersprint(course_name.upper()) # Returns a string in upper-case lettersprint(course_name.swapcase()) # Returns a string with upper-case and lower-case letters swappedprint(course_name.title()) # Returns a string with upper-case first letter of each word, lowercase for remaining textprint(course_name.capitalize()) # Returns a string with upper-case first letter only, lowercase for remaining text
</source>
:#Strings have many built-in functions that we can use to manipulate text. Let's take a look at the strings name space and the available functions:<source>dir(course_name)help(course_name)</source>:#Lets try out several different functions. Refer back to the '''help()''' function for more information, these are quick ways to view strings in different ways. Issue the following:<source>course_name.lower() # Returns a string in lower-case letterscourse_name.upper() # Returns a string in upper-case letterscourse_name.swapcase() # Returns a string with upper-case and lower-case letters swappedcourse_name.title() # Returns a string with upper-case first letter of each word, lowercase for remaining textcourse_name.capitalize() # Returns a string with upper-case first letter only, lowercase for remaining text</source>:#These values can be saved inside new strings and then reused:<sourcelang="python">
lower_name = course_name.lower() # Save returned string lower-case string inside new string variable
print(lower_name)
lower_name.split(' ') # Provide the split() function with a character to split on
</source>The above example will return a list of strings, which we can access just like all of lists. <br><br>
:#Let's practice more string manipulation by issuing the following:<sourcelang="python">
list_of_strings = lower_name.split(' ') # Split string on spaces and store the list in a variable
print(list_of_strings ) # Display listprint(list_of_strings[0] ) # Display first item in list</source>Since lists are actually a list of '''strings''', you should be able to use any function that works with a string on a list.<br><br>:#To demonstrate, issue the following:<sourcelang="python">
list_of_strings[0].upper() # Use the function after the index to affect a single string within a list
first_word = list_of_strings[0]
first_word
print(first_word)
</source>The '''index''' that is used to access <u>items</u> within a list, can also be used to access <u>characters</u> within a string. For practice, let's create a new string, and start accessing the strings index.<br><br>:#Issue the following:<source>
course_name = 'Open System Automation'
course_code = 'OPS435'
course_number = 435
print(course_code[0] ) # Return a string that is Print the first character in course_codeprint(course_code[2] ) # Return a string that is Print the third character in course_codeprint(course_code[-1] ) # Return a string that is Print the last character in course_codeprint(str(course_number)[0] ) # Turn the integer into a string, return first character in that string, and print itprint(course_code[0] + course_code[1] + course_code[2])</source>:#You can use a technique that uses index numbers of a string to '''cut-out''' or '''"parse"''' smaller portions of text within a string. This term is referred to as a '''substring'''. We can use this to create a new string or display only a small portion of it<br><br>:#To demonstrate, issue the following:<sourcelang="python">print(course_name[0:4] ) # Return Print the first four characters (values of index numbers 0,1,2, and 3)
first_word = course_name[0:4] # Save this substring for later use
print(course_code[0:3] ) # Return Print the first three characters (values of index numbers 0,1,and 2)
</source>
:# The index allows a few '''extra functions''' using the same parsing technique:<sourcelang="python">
course_name = 'Open System Automation'
print(course_name[12:] ) # Return Print the substring '12' index until end of stringprint(course_name[5:] ) # Return Print the substring '5' index until end of stringprint(course_name[-1] ) # Return Print the last character</source>With '''negative indexesindices''', '''-1''' index would represent the '''last''' character, '''-2''' index would represent the '''second last''' character, etc.<br><br>:#To demonstrate, issue the following:<sourcelang="python">
course_name = 'Open System Automation'
print(course_name[-1])print(course_name[-2])
</source>
:# Issue the following to practice Practice some of the skills that you have learned in this section:<source>
course_name = 'Open System Automation'
print(course_name[-10:] ) # Return the last ten charactersprint(course_name[-10:-6] ) # Try and figure out what this is returning print(course_name[0:4] + course_name[-10:-6] ) # Combine substrings together
substring = course_name[0:4] + course_name[-10:-6] # Save the combined substring as a new string for later
print(substring)
</source>
:# The real power found in substrings goes beyond just manually writing index values and getting back words. The next part of this investigation will cover how to search through a string for a specific word, letter, number, and return the index to that search result.
'''Create a Python Script Demostrating Substrings'''
:'''Perform the Following Instructions'''
::#Create the '''~/ops435/lab4/lab4d.py''' script. The purpose of this script is to demonstrate creating and manipulating strings. There will be four functions each will return a single string.::#Use the following template to get started:<source>
#!/usr/bin/env python3
# Strings 1
</source>
:::*The script should contain '''four''' functions (use your own argument names)::::::'''first_five()''':<ol><li>Accepts a single string argument</li><li>Returns a string that contains the first five characters of the argument given</li></ol>:::::'''last_seven()''':<ol><li>Accepts a single string argument</li><li>Returns a string that contains the last seven characters of the argument given</li></ol>:::::'''middle_number()''':<ol><li>Accepts a integer as a argument</li><li>Returns a string containing the second and third characters in the number</li></ol>:::::'''first_three_last_three()''':<ol><li>Accepts two string arguments</li><li>Returns a single string that starts with the first three characters of argument1 and ends with the last three characters of argument2</li></ol>:::*Example: first_three_last_three('abcdefg', '1234567') returns single string 'abc567'::::'''Sample Run 1'''<source>run ./lab4d.py
Hello
Senec
Send!!
</source>
::::'''Sample Run 2(with import)'''<source>
import lab4d

str1 = 'Hello World!!'
str2 = 'Seneca College'
num1 = 1500
num2 = 1.50
print(lab4d.first_five(str1))# Will output 'Hello'print(lab4d.first_five(str2))# Will output 'Senec'print(lab4d.last_seven(str1))# Will output 'World!!'print(lab4d.last_seven(str2))# Will output 'College'print(lab4d.middle_number(num1))# Will output '50'print(lab4d.middle_number(num2))# Will output '.5'print(lab4d.first_three_last_three(str1, str2))# Will output 'Helege'print(lab4d.first_three_last_three(str2, str1))# Will output 'Send!!'
</source>
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
ls CheckLab4.py || wget matrix.senecachttps://raw.ongithubusercontent.cacom/~acoatleySeneca-willisCDOT/ops435/master/LabCheckScripts/CheckLab4.py
python3 ./CheckLab4.py -f -v lab4d
</source>
= LAB 4 SIGN-OFF (SHOW INSTRUCTOR) =
698
edits