Computer Science
Which of the following statements is false about recursion?
- Every recursive function must have a base case.
- Infinite recursion can occur if the base case isn't properly mentioned.
- A recursive function makes the code easier to understand.
- Every recursive function must have a return value.
Python Functions
2 Likes
Answer
Every recursive function must have a return value.
Reason — The statement "Every recursive function must have a return value" is false because recursive functions in Python don't necessarily have to return a value.
Answered By
1 Like
Related Questions
Which is the most appropriate definition for recursion?
- A function that calls itself
- A function execution instance that calls another execution instance of the same function
- A class method that calls another class method
- An inbuilt method that is automatically called
Fill in the line of code for calculating the factorial of a number:
def fact(num): if num == 0: return 1 else: return...............
- num*fact (num-1)
- (num-1) * (num-2)
- num* (num-1)
- fact (num) *fact (num-1)
What is the output of the following snippet?
def fun(n): if (n > 100): return n - 5 return fun (fun (n+11) ) print(fun(45))
- 50
- 100
- 74
- Infinite loop
What happens if the base condition isn't defined in recursive programs?
- Program gets into an infinite loop
- Program runs once
- Program runs n number of times, where n is the argument given to the function
- An exception is thrown