Question: part 1 PYTHON ill be leaving a thumbs up! Problem 1 [30 points ] Recursive functions. In this problem, you are asked to write three
Problem 1 [30 points ] Recursive functions. In this problem, you are asked to write three recursive functions. All three functions should be implemented in a module called problem1.py. Please note the following important points. - You may not use any built-in functions other than len, the index operator [] , the slice operator [:], and + (string or list concatenation). - You also may not use any loops. - The built-in function in is essentially a loop and may not be used in any of the functions in this question. 1. [10 points] Write a recursive function called remove_char with two parameters: a string astr and a character ch. The function returns a string in which all occurrences of ch in astr are removed. For example, remove_char ("object oriented", 'e') returns the string "objct orintd". As stated above, you may not use any built-in functions for strings. 2. [10 points] Write a recursive function called num double_letters with a single string parameter astr that returns the number of occurrences of double letters in astr. A double letter is simply a consecutive pair of the same character. For example, num_double_letters ("mississippi") should return 3 because double letters occur 3 times in the string ("ss", "ss", and "pp"). Note that if the same letter occurs consecutively three or more times (this doesn't happen too often in English!), we only count non-overlapping double letter pairs. For example, num_double-letters ("hmmm") should return 1 because there is only one non-overlapping occurrence of the double letters mm, whereas num_double_letters ("hmmmm") should return 2. 3. [10 points] Write a recursive function called positive_product with a single parameter L, which is a list of non-zero integers. The function returns True if the product of all integers in L is positive and False otherwise. We assume that the list has length at least 2. The base case occurs when L has length 2 . For example, if L=[4, 9,9,6,1,2,1,1], positive product (L) returns False. If L=[5,4], positive-product ( L ) returns True. Your function implementation should consist only of if-else statements, list index [] and slice [:] operators, and recursive calls to positive-product. There should not be any loops (for or while) in your implementation. You may not use any built-in functions other than len
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
