Question: Q1) Write a recursive function mylen(some_list) that determines the length of a list some list passed as an argument to this function. Call the function

 Q1) Write a recursive function mylen(some_list) that determines the length of

Q1) Write a recursive function mylen(some_list) that determines the length of a list some list passed as an argument to this function. Call the function by writing the following piece of code: def main(): alist [43,76,97,86] print (mylen(alist)) main() The output of the above program segment would be: 4 NOTE: The function mylen should work with any list VERY IMPORTANT: your function cannot call the built-in Python function len()! Q2) Write a recursive function called isEven that returns True if number is even or returns False if number is odd Call the function by writing the following piece of code: def main(): nint(input("enter a number: ")) print("is", n, "even?", isEven (n)) main If the user enters 6 the output of the above program would be: Is 6 even? True If the user enters 13 the output of the above program would be: Is 13 even? False NOTE: You can assume that the user always enters a valid positive integer number. HINT : Subtracting 2 from an even number would eventually yield 0. Subtracting 2 from an odd number would eventually yield 1 Q3) Write a recursive function that computes and returns the sum of digits of an integer. Call the function by writing the following code: def main (): number-int(input( 'Enter a number:')) print (sumdigits (number)) main If the user enters the number 78411 the output of the above program would be: 21 NOTE: You can assume that the user always enters a valid positive integer number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!