Question: Python 3 Please show the answer in Pyhcarm. I appreciate it. Preliminaries For this lab you will be working with regular expressions in Python. Various

Python 3

Please show the answer in Pyhcarm. I appreciate it.

Python 3 Please show the answer in Pyhcarm. I appreciate it. Preliminaries

Preliminaries For this lab you will be working with regular expressions in Python. Various functions for working with regular expressions are available in the re module. Fortunately, Python makes it pretty easy to see if a string matches a particular pattern. At the top of the file we must import the re module import re Then we can use the search ( function to test whether a string matches a pattern. In the example below, the regular expression has been saved in a string called pattern for convenience phone123-456-7890 pattern = r^^ \d( 3 }-\d { 3 }-\d { 4 } $, if re.search (pattern, phone): print ('The string matches the pattern.') else: print('The string does not match the pattern.') The r that precedes the pattern string is not a typo. Rather, the r indicates that the string is a "raw" string. In a raw string, as opposed to a "normal" string, any backslash character is interpreted as simply a backslash, as opposed to defining an escape sequence like In or t. Make sure you use raw strings in your Python code whern defining regular expressions. The and $ at the beginning and end of the regular expression indicate that the entire string must match the regular expression, and not just part of the string. Make sure you include these symbols in your regular expressions too! Part I: MAC Address Checker (20 points) Write a function mac.checker that takes one parameter, 'macs', which is a non-empty list of strings, each being a potential MAC address. (A MAC address is a ID number burned into the circuit of a network interface card.) Your function should examine each string in the list and return a list of indexes of the strings which meet the following description/requirement: A valid MAC address string is a composition of six parts, with a semicolon between them. Each one of those six parts contains exactly two hexadecimal digits, meaning the two digits can only be a composition of 0-9 or A-F (letters must be capitalized). It is possible that macs contains no valid MAC addresses, in which case the function should return an empty list. Examples: macs1 = macs2 = macs3 = [,CE : 9B : F1 :02 : 94 : 4 9 , , ,30 :CF : 39:7E:E6:9C" , [15E : IE : 2 3 : 44 : 9F : 17','1P:CC : DD : EE : FF : 11 , , [,9| : 13 : 6B : 5C : 3E :FF , , ,DD : D 1 : 5a : 4F:2F :D4 , , ,3D : 49:C7:23:89:E8"] ,1D : D3,C1:1C:32 : 65' ] ,A1 : FC:54:AB ! 92:55'] Function Call mac.checker (macs1) [0, 1, 2] mac.checker (macs2)[0] mac.checker (macs3) [0] Return Value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!