# Author: # Date: ########### The problems come in pairs ########### ############### Problem 1 ######################### ######### B- level for two ################## def snip_char(s, ch): """prec: s is a string, ch is a character if the string does not contain the character the entire string is returned if it does, that character and everything after it is amputated and the remainder is returned. examples: snip_char("cowpie", "i") -> "cowp" snip_char("Moosement, "M") -> "" snip_char("Heffalump, "z") -> Heffalump""" return "" ############### Problem 2 ######################### ######### B- level for two ################## def double_speak(s): """prec: s is a string postc: returns s with its characters doubled. examples: double_speak("cat") -> "ccaatt" double_speak("") -> "" """ return "" ############### Problem 3 ######################### ########## B level for 1, A-/B_ for two########### def eval_dict(d): """prec: d is a dictionary whose keys are numbers and whose values are nonnegative integers. postc: returns the product of the keys raised to their values' powers. examples: eval_dict({4:2, 5:3, 3:2}) -> 4**2 * 5**3 * 3**2 = 16*125*9 = 18000. return 1 if the dictionary is empty. """ return 1 ############### Problem 4 ######################### ########## B level for 1, A-/B_ for two########### def file_in_place(x, new_item): """prec: x is a homogeneous list of sortable items that is sorted. (Note: x could be empty) postc: new_item is an object of the list's item type. the new items is inserted into the list so the list is still sorted. NB: the list is altered in-place. You do not return a copy. example: x = [2,4,6,8] new_item = 7 file_in_place(x, new_item) changes x to [2,4,6,7,8] x = [] new_item = "cows" file_in_place(x, new_item) changes x to ["cows"] """ pass ############### Problem 5 ######################### ########## A level for 1, A+ for two ########### def flatten(x): """prec: x is a list postc: returns a new list which has been "flatted" by removing and extending all nexted lists. examples: flatten([1, 2, 3]) -> [1, 2, 3] flatten([[1,2], [3, [4, 5], 6], 7, 8]) -> [1, 2, 3, 4, 5, 6, 7, 8] """ return [] ############### Problem 6 ######################### ########## A level for 1, A+ for two ########### def push_me_pull_you(file_name, ch): """prec: file_name is the name of an existing file ch is a character. postc: prints all lines containing a word that begins and ends with the character ch. My test file will have no punctuation mark. This is case-sensitive""" pass print("****************** Test Problem 1 *******************") print("****************** Test Problem 2 *******************") print("****************** Test Problem 3 *******************") print("****************** Test Problem 4 *******************") print("****************** Test Problem 5 *******************") print("****************** Test Problem 6 *******************")