Question: 1. Write a recursive function mylen(l) that determines the length of a list l passed as a parameter. Call the function by writing the following

1. Write a recursive function mylen(l) that determines the length of a list l passed as a parameter.

Call the function by writing the following piece of code:

def main():

alist=[43,76,97,86]

print(mylen(alist))

main()

NOTE: The function mylen should work with any list

VERY IMPORTANT: your function cannot call the built-in Python function len()!

2. Write a recursive function called isEven that finds whether a number is even or not.

Call the function by writing the following piece of code:

def main():

number=int(input("Enter a number : "))

if (isEven(number)):

print("Number is even)

else: print("Number is not even)

main()

NOTE: You can assume that the user always enters a positive integer number.

3. Write a recursive function that computes 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()

NOTE: You can assume that the user always enters a positive integer number.

4. Write a recursive function that displays an integer value reversely on the console. For example a call to reverseDisplay(12345) should display 54321. Call the function by writing the following code:

def main():

number=int(input("Enter a number :))

reverseDisplay(number)

main()

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!