#################################### # Author: PUT YOUR NAME HERE # Date created: 18 Aug 2020 # Date last modified: 18 Aug 2020 # Program: stringPlay.py # #################################### ################sample solution########## ###############Problem 0################# def get_between(arg, letter): """precondition: arg is a string in which the specified letter occurs at least twice, letter is a one-character string postcondition: this function returns a new string with the characters between the first and last instance of letter in the string """ start = arg.find(letter) end = arg.rfind(letter) return arg[start + 1: end] ##You have a solution manual. Generate some test cases ##as seen here. Create at least one for each function. arg = "quoque" letter = "q" result = "uo" print("PASS" if result == get_between(arg, letter) else "FAIL") arg = "robber" letter = "r" result = "obbe" print("PASS" if result == get_between(arg, letter) else "FAIL") ###############Problem 1################# def remove_letter(arg, letter): """arg is a string, letter is a one-character string remove all instances of letter from arg, both upper and lower case""" pass #possible grist for a test case.... arg = "Sissyphus" # your code goes here. result = "iyphu" ###############Problem 2################# def eviscerate(arg, letter): """arg is guaranteed to have at least two letters and to be an alphabetical string return a string with the first and last letters of arg.""" pass ##grist for testing arg = "heinous" result = "hs" ##grist for testing arg = "Washington" result = "Wn" ###############Problem 3################# def frankenstein(head, tail): """head has an even number of letters tail has an even number of letters return a string whose first half is the first half of head and the second half of tail.""" ##test grist head = "cerebellum" tail = "wagger" result = "cereger" ###############Problem 4################# def letter_count(arg, letter): """ arg is a string, letter is a one-character string returns the number of times letter appeaers in arg, case insensitive""" ##test grist. arg = "Babbage" result = 3 ###############Problem 5################# def letter_count_partial(arg, letter, n): """arg is a string, letter is a one-character string, and n is an integer 0 <= n <= len(letter) return the number of instances of letter in the first n characters of the string arg""" pass ##grist for testing. arg = "Babbage" result = 3 arg = "flibbertygibbet" result = 2 ###############Problem 6################# def marquee(arg, ch, n): """arg is a string, ch is a one-character string and n is an integer, n >= 0 returns the string arg centered in a string of length n, padded with character ch. If n < len(arg), it just returns arg(no conditional logi on your part needed)""" pass # test grist arg = "wabbit" result = "!!!!!!!!!!!!wabbit!!!!!!!!!!!!" ###############Problem 7################# def doodle(arg, ch): """arg is any string get rid of all of the whitespace on the left, if any replace any spaces on the right with ch and return the result.""" pass #test grist arg = " wabbit " result = "wabbit@@@@"