3
answers
0
watching
276
views
23 Oct 2018
Question 5. [7 MARKS] Part (a) (6 MARKS) Write the body of the following function according to its docstring description. def numeric-phone (alphanumeric_phone, mapping): (str, list of str) -> int Preconditions: - len(mapping) <= 10 - alphanumeric-phone contains only digits and uppercase letters - each letter in alphanumeric_phone is guaranteed to appear in mapping once - mapping may contain letters not in alphanumeric-phone Return a numeric phone number that corresponds to alphanumeric_phone. Each letter from alphanumeric-phone is replaced with the index of the item from mapping that contains the letter. Digits are not replaced. >>> numeric-phone ('416310BELL', ['ABC', 'DEF', 'GHI', 'JKL', 'NO', 'PQRS', 'TUV', 'WXYZ']) 4163100133
Question 5. [7 MARKS] Part (a) (6 MARKS) Write the body of the following function according to its docstring description. def numeric-phone (alphanumeric_phone, mapping): (str, list of str) -> int Preconditions: - len(mapping) <= 10 - alphanumeric-phone contains only digits and uppercase letters - each letter in alphanumeric_phone is guaranteed to appear in mapping once - mapping may contain letters not in alphanumeric-phone Return a numeric phone number that corresponds to alphanumeric_phone. Each letter from alphanumeric-phone is replaced with the index of the item from mapping that contains the letter. Digits are not replaced. >>> numeric-phone ('416310BELL', ['ABC', 'DEF', 'GHI', 'JKL', 'NO', 'PQRS', 'TUV', 'WXYZ']) 4163100133
29 Jun 2023
supertorksLv1
10 Apr 2023
Already have an account? Log in
Nestor RutherfordLv2
25 Oct 2018
Already have an account? Log in