Do not add any imports, the ones that you need will be given to you. Do not use try-except statements, you should be able to anticipate or prevent any errors from happening at all! str:Given a string...


Do not add any imports, the ones that you need will be given to you.
Do not use try-except statements, you should be able to anticipate
or prevent any errors from happening at all!


def find enail(s: str) -> str:<br>Given a string <s>, return the emoil that exists in the string.<br>Preconditions:<br><s> contains at most 1 emoil, or none ot oll.<br>If cs> does not contain on email, return the empty string.<br>Email definition:<br>An emoil oddress is defined os 'nomeadomain.com' or 'nane@domoin.co'<br>with the following specifications:<br>name: the nome is on olphanuneric string that is less than or<br>equol to 12 charocters. Additional charocters ollowed are<br>dash (-), period (.) and underscore (). But the emoilL<br>cannot start or end with these odditional characters.<br>The name must olso be ot least 1 character Long.<br>Example names:<br>ob<br>o_b<br>A_B..C--D<br>Int3ršst. Ing<br>domain: the domain is strictly numericol, and the number must be<br>divisible by 5. the Length of the domain is unrestricted.<br>Example donains:<br>984125<br>ending: the email must end with a (.com) or (.ca) (cose sensitive)<br>Note: you mUst not use any Loops (for, while) here.<br>We want you to just use the re Library for this function.<br>d_emoil('12345o_test_email@165265365. com!')<br>'a_test_email@l165265365. com<br>reg =

Extracted text: def find enail(s: str) -> str: Given a string
, return the emoil that exists in the string. Preconditions:

contains at most 1 emoil, or none ot oll. If cs> does not contain on email, return the empty string. Email definition: An emoil oddress is defined os 'nomeadomain.com' or '[email protected]' with the following specifications: name: the nome is on olphanuneric string that is less than or equol to 12 charocters. Additional charocters ollowed are dash (-), period (.) and underscore (). But the emoilL cannot start or end with these odditional characters. The name must olso be ot least 1 character Long. Example names: ob o_b A_B..C--D Int3ršst. Ing domain: the domain is strictly numericol, and the number must be divisible by 5. the Length of the domain is unrestricted. Example donains: 984125 ending: the email must end with a (.com) or (.ca) (cose sensitive) Note: you mUst not use any Loops (for, while) here. We want you to just use the re Library for this function. d_emoil('12345o_test_email@165265365. com!') 'a_test_email@l165265365. com reg = "([a-zA-ZB-91{1}[a-zA-Z0-9+_.J{1,11})@([0-9]+) [5][.J([a-zA-Z]+)" m = re.search(reg, s) if (m == None): mail = else: mail - n.group() return mail
def test_template (f: Callable) -> None:<br>This is a template for the tests you will write for this lab.<br>Implement your tests as top level functions that begin with the<br>word 'test' and take in a callable function <f>.<br>You are free to do some amount of work to construct your tests cases<br>within the function but your function must end with an assert statement<br>of the form <assert f('string') == 'some string'>.<br>An assert statement means that you expect the boolean expression following<br>to evaluate to True. With regards to this lab, it means that you expect the<br>function call on the left to return the string on the right. If this does<br>not happen, then the assert statement will raise an AssertionError, which<br>we will catch and take it to mean that this particular test failed.<br>IMPORTANT:<br>The goal of this part of the lab is to write a set of tests such that that<br>ALL of them pass for any correct implementation, but AT LEAST ONE of them<br>fail for any incorrect implementation (of

Extracted text: def test_template (f: Callable) -> None: This is a template for the tests you will write for this lab. Implement your tests as top level functions that begin with the word 'test' and take in a callable function . You are free to do some amount of work to construct your tests cases within the function but your function must end with an assert statement of the form . An assert statement means that you expect the boolean expression following to evaluate to True. With regards to this lab, it means that you expect the function call on the left to return the string on the right. If this does not happen, then the assert statement will raise an AssertionError, which we will catch and take it to mean that this particular test failed. IMPORTANT: The goal of this part of the lab is to write a set of tests such that that ALL of them pass for any correct implementation, but AT LEAST ONE of them fail for any incorrect implementation (of "find_email"). assert f('[email protected]') '[email protected]' ==

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here