89. code in python. please use the same template in the picture, also down below. and provide code. thnx user_input = in
Posted: Fri May 20, 2022 3:38 pm
89. code in python. please use the same template in the picture,
also down below. and provide code. thnx
user_input = input()
def letterToInt(s):
letter = ('A': 1, 'E': 5, 'J': 10, 'O': 15, 'T': 20, 'Z': 26, 'YY':
50}
# TODO: Read input string, parse it to find the corresponding
numeric value
print(letterToInt(user_input))
Using the template code as a starting point, write a program that reads a string of letters as input and produces output that is either a number or an error message. The output number should equal the sum of the values assigned to the letters (defined below). The program should output the error message if the input contains any characters that are not defined below. The error message should read "Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, Z, YY." Your template code creates a list of letters and assigns each letter a number value: Letter Number A 1 E 5 J 10 J o 15 T 20 Z 26 YY 50 NOTE 1: The final value in the list (YY) is a two-letter combination that must appear in full in order to be considered valid input. NOTE 2: A space is not a valid input character. HINT: You may use string[start:end] to parse the input string and extract the numeric integer for the "YY" combination. Example 1: If the input is TEA the output should be 26
Example 1: If the input is TEA the output should be 26 Example 2: If the input is JOYY output should be 75 Example 3: If the input is JOY the output should be Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, 2, YY. Input to program If your code requires input values, provide them here.
n Undo Redo a main.py Load default template... HNM N O 1 user_input input() I 2 3 def letterToInt(s): 4 letter = {'A': 1, 'E': 5, 'j': 10, 'O': 15, 'T': 20, 'Z': 26, 'YY': 50} 5 # TODO: Read input string, parse it to find the corresponding numeric value 6 7 8 print(letterToInt(user_input))
also down below. and provide code. thnx
user_input = input()
def letterToInt(s):
letter = ('A': 1, 'E': 5, 'J': 10, 'O': 15, 'T': 20, 'Z': 26, 'YY':
50}
# TODO: Read input string, parse it to find the corresponding
numeric value
print(letterToInt(user_input))
Using the template code as a starting point, write a program that reads a string of letters as input and produces output that is either a number or an error message. The output number should equal the sum of the values assigned to the letters (defined below). The program should output the error message if the input contains any characters that are not defined below. The error message should read "Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, Z, YY." Your template code creates a list of letters and assigns each letter a number value: Letter Number A 1 E 5 J 10 J o 15 T 20 Z 26 YY 50 NOTE 1: The final value in the list (YY) is a two-letter combination that must appear in full in order to be considered valid input. NOTE 2: A space is not a valid input character. HINT: You may use string[start:end] to parse the input string and extract the numeric integer for the "YY" combination. Example 1: If the input is TEA the output should be 26
Example 1: If the input is TEA the output should be 26 Example 2: If the input is JOYY output should be 75 Example 3: If the input is JOY the output should be Error: Input contains an invalid character. Valid input characters are A, E, J, O, T, 2, YY. Input to program If your code requires input values, provide them here.
n Undo Redo a main.py Load default template... HNM N O 1 user_input input() I 2 3 def letterToInt(s): 4 letter = {'A': 1, 'E': 5, 'j': 10, 'O': 15, 'T': 20, 'Z': 26, 'YY': 50} 5 # TODO: Read input string, parse it to find the corresponding numeric value 6 7 8 print(letterToInt(user_input))