Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Restrictions Do not import any modules other than math and check. You are always allowed to define your own helper / wrapper functions, as long
Restrictions
Do not import any modules other than math and check. You are always allowed to define your own helperwrapper functions, as long as they meet the assignment restrictions. Do not use Python constructs from later modules eg fstrings, dictionaries, loops for or while or others zip, functions with default parameters, sorted, anything with sets or enumerators andor lists, ord, chr try and except Use only the functions, methods, operations, constants and keywords as follows:
abs len, max, and min however keyword parameters for these functions are not allowed
Any method or constant in the math module
Any basic arithmetic or comparison operations
Any basic logical operators not and, or
or just before the seventh digit,or before both the fourth and seventh digits.
For example, and are all valid phone numbers.These typecasting operators: int str float bool and type
if statements including elif and else
String slicing and indexing as well as string operations using the operators above.
String methods: capitalize, count, endswith, find, index, isalnum, isalpha, isdecimal, isdigit, islower, isnumeric, isspace, istitle, isupper, lower, lstrip, replace, rfind, rindex, rstrip, startswith, strip, swapcase, title, upper, zfill
The operation in for strings.
input and print as well as the formatting parameter end and method format. Note that all prompts must match exactly in order to obtain marks so ensure that you do not alter these prompts.
Recursion
Skeleton:import check
inputprompt "Please enter a valid phone number:
errormsg "Invalid phone number."
def phonenumber:
##YOUR CODE GOES HERE
pass
## Test for given example
check.setprintexacterrormsg
check.setinput
check.expectExample phonenumber
## Test for given example
check.setprintexacterrormsg errormsg errormsg errormsg
check.setinputnnnn
check.expectExample phonenumber None
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started