Question: SUBJECT PYTHON Before next lesson, upload this lab to the learning hub at learn.bcit.ca in the /Activities/Assignments/Lesson9Lab dropbox. A sample solution will be posted at
SUBJECT PYTHON
Before next lesson, upload this lab to the learning hub at learn.bcit.ca in the /Activities/Assignments/Lesson9Lab dropbox. A sample solution will be posted at the start of the next lesson, so late submissions are not accepted. Write a python script with the following four functions that use regular expressions created by you:
Function name Returns True if the parameter matches this pattern
isValidBCLicensePlate Six characters total: three letters then three digits, or three digits then three letters,
or two letters, digit, space or hyphen, two digits, letter All letters are UPPERCASE
Example matches:
ABC123
123ABC
AB1 23C
AB1-23C
isValidPythonVariable
Name Between one and 32 characters total: all characters must be lowercase letters or underscores, but not more than one underscore in a row
Example matches:
first_name
x
a_good_variable_name
isValidEmailAddress
HINT: break down the
parameter as follows: def isValidEmailAddress(email): email_data = re.split('@', email) username = email_data[0] domain_data = re.split('[.]', email_data[1]) domain_name = domain_data[0] top_level_domain = domain_data[1] Username followed by @ followed by domain name followed by period followed by top-level-domain. Username rules: letters (upper or lower case) and underscores (as long as _ is neither the first nor last character): between 1 and 256 characters total Domain name rules: letters (upper or lower case) between 1 and 32 characters total Top-level-domain rules: letters (upper or lower case) between 2 and 5 characters total. Example matches: Jason_Harrison@bcit.ca a_____b@c.com isValidHumanHeight Number of feet, apostrophe, number of inches, double quotation mark. The number of feet must be 2-8 inclusive. The number of inches must be 0-11 inclusive. The number of inches between 0 and 9 may have an optional leading zero (e.g. 508 or 58) The shortest height is 21 (not 20) and the tallest height is 811 Note: instead of double quotation marks for inches, you can accept the word in instead. Example matches: 201 21 509 62in 410in 62 811
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
