Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function mac checker() that takes one parameter, macs, which is a non-empty list of strings, each being a potential MAC address. Please Use

Write a function mac checker() that takes one parameter, macs, which is a non-empty list of strings, each being a potential MAC address.

image text in transcribed

Please Use python to solve the problem.

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 CSE 101 - Fall 2017 Lab #11 Page 1 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: phone = , 123-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 or \t. Make sure you use raw strings in your Python code when 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 : F 1 : 02:94:49, , ["5E : 1E:23:44:9F : 17', [,9I : 13 : 6B : 5C : 3E : FF , , ,30 :CF 39:7E:E6:9C' , '1P:CC : DD : EE : FF : 1 1 , , ,DD : DI : 5a : 4F:2F : D4 , , ,3D:49:C7:23:B9: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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

The 2004 CSI MasterFormat is broken down into how many divisions?

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago