Question: WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS (100 Pts) (a) (10 Pts) [Task-1] Define a function called repeat letters that takes a
WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS (100 Pts) (a) (10 Pts) [Task-1] Define a function called repeat letters that takes a string and a number n as two parameters and prints the string with every letter repeated n times. Sample input/Output: print(repeat letters ("medipol", 3)) "mmmeeedddizipppooolll" (b) (10 Pts) [Task-2] Define a function called find_index which takes as argument a word and a letter. It will return the index of the second occurrence of the letter in the given word. Sample input/Output: print(find index("welcomehome", "e")) 6 (c) (10 Pts) [Task-3] Define a function called list_unique that takes a string str as an input, checks all letters of the string, and constructs a list that contains the list of character that appear in str. This list should not contain any duplicates. Sample input/Output: print(list_unique("ankara")) ['a', 'n', 'k', 'r'] (d) (10 Pts) [Task-4] Write a function called ngrams list that takes a string and a number n and return the n-grams of the this string as a list Sample input/Output: print(ngrams_list("computer", 2)) ["co","om","mp", "pu", "ut", "te", "er"] 2
Step by Step Solution
There are 3 Steps involved in it
The image shows a programming assignment with four tasks each requiring the definition of a specific ... View full answer
Get step-by-step solutions from verified subject matter experts
