Question: Use python to do it please send me a picture or a link to download the python file. CMPUT 175 LAB 02 You are

Use python to do it

please send me a picture or a link to download the python file.

"""

CMPUT 175

LAB 02

You are provided with four empty functions. You should write code inside

these functions so that they perform as required. Each function also contains

instructions in the form of comments on the how to complete them. Please read

the comments carefully.

* Note that you are NOT allowed to import any other modules.

"""

LEN = 12

POS_HYPHEN_1 = 3

POS_HYPHEN_2 = 7

def check_length(phone_number):

"""

This function should determine if the length of the phone_number is correct

"""

return True

def check_hyphens(phone_number):

"""

This function should determine if the hyphens are at the correct positions

"""

return True

def check_digits(phone_number):

"""

This function should determine if all the characters other than the

hyphens are digits

"""

return True

def modify(phone_number):

"""

Given a valid phone_number, this function should replace the

largest digits with 'X' and the second largest digits with 'Y'

"""

modified_phone_number = ''

return modified_phone_number

def validate(phone_number):

"""

This function should check if phone_number input by the user is valid

Return True if its valid otherwise return False

"""

# Test the length of the phone number

if check_length(phone_number) != True:

return False

# Test if the hyphens are placed correctly

if check_hyphens(phone_number) != True:

return False

# Test if the digits are placed correctly

if check_digits(phone_number) != True:

return False

return True

def main():

while True:

phone_number = input('Enter a phone number: ')

# If the User enters an empty string: Exit

if phone_number == '':

return

# Test if the number is valid

if not validate(phone_number):

print ('The phone number is not valid')

else:

# If the number is valid, replace the largest digit with X

# and the second largest with Y

print (modify(phone_number))

if __name__ == '__main__':

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!