Quiz on Recursion in Python
FREE Online Courses: Elevate Your Skills, Zero Cost Attached - Enroll Now!
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which of the following best defines the recursion of a function?
CorrectIncorrect -
Question 2 of 15
2. Question
Which of the following is true about a recursive function?
CorrectIncorrect -
Question 3 of 15
3. Question
What does infinite recursion mean?
CorrectIncorrect -
Question 4 of 15
4. Question
What is the output of the below code?
def func(x):
if(x==0 or x==1):
return 1
return func(x-1)*x
func(6)
CorrectIncorrect -
Question 5 of 15
5. Question
Which of the following function calls lead to infinite recursion in the below code?
def fun(a):
if(a==0):
return 0
return a*fun(a-1)
CorrectIncorrect -
Question 6 of 15
6. Question
What does the function in the below code do?
def func(x):
if(len(x)==0):
return True
if x[0]!=x[-1]:
return False
return func(x[1:-1])
CorrectIncorrect -
Question 7 of 15
7. Question
Which of the following is a disadvantage of recursive function?
CorrectIncorrect -
Question 8 of 15
8. Question
What is the output of the below code?
def func(x):
if x==0:
return 0
return x+func(x-1)
func(-5)
CorrectIncorrect -
Question 9 of 15
9. Question
Which of the following is true about tail recursion?
CorrectIncorrect -
Question 10 of 15
10. Question
What is the output of the below code?
def fun(a):
if(a>50):
return a-3
return fun(fun(a+5))
CorrectIncorrect -
Question 11 of 15
11. Question
To find the length of the sequence in a recursive way, in the below code find the missing statement.
def length(seq):
if(bool(seq)==False):
return 0
**missing line**
CorrectIncorrect -
Question 12 of 15
12. Question
What is the output of the below code?
def func(x):
if(len(x)==0):
return
print(x[0]%2==0,end=” “)
return func(x[1:])
func([1,2,3,4,5])
CorrectIncorrect -
Question 13 of 15
13. Question
How many times does the below function recur?
def func(x):
if(x>20):
return 0
if(x%2):
return 1+func(x+1)
return 1+func(x+3)
func(1)
CorrectIncorrect -
Question 14 of 15
14. Question
For the function calculating the sum of all natural numbers till n, which of the following base suits the best?
CorrectIncorrect -
Question 15 of 15
15. Question
Find the output of the below code.
def fun(s):
if(len(s)==1):
return s[0].upper()
return fun(s[:-1])+s[-1].lower()
CorrectIncorrect