Answered step by step
Verified Expert Solution
Link Copied!

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 helper/wrapper functions, as long as they meet the assignment restrictions. Do not use Python constructs from later modules (e.g. fstrings, dictionaries, loops (for or while or others), zip, functions with default parameters, sorted, anything with sets or enumerators and/or 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, '5198884567','(519)8884567','(519)888-4567','519-8884567','519888-4567' and '519-888-4567' 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
input_prompt = "Please enter a valid phone number: "
error_msg = "Invalid phone number."
def phone_number():
##YOUR CODE GOES HERE
pass
## Test for given example 1
check.set_print_exact(error_msg)
check.set_input("519","(519)888-4567")
check.expect("Example 1", phone_number(),"5198884567")
## Test for given example 2
check.set_print_exact(error_msg, error_msg, error_msg, error_msg)
check.set_input("n","n","n","n")
check.expect("Example 2", phone_number(), None)
image text in transcribed

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago

Question

What are some of the possible scenes from our future?

Answered: 1 week ago