Python Recursion

Python Recursion

12th Grade

10 Qs

quiz-placeholder

Similar activities

Evaluación Diagnóstica de Computación

Evaluación Diagnóstica de Computación

6th Grade - University

12 Qs

ASK FORM 3 MICROSOFT ACCESS

ASK FORM 3 MICROSOFT ACCESS

KG - University

10 Qs

Python (I)

Python (I)

12th Grade

14 Qs

Series

Series

12th Grade

10 Qs

Python -Variables

Python -Variables

12th Grade

10 Qs

1.2.4. Types of Programming Language

1.2.4. Types of Programming Language

12th Grade

12 Qs

Test on Python Function

Test on Python Function

11th - 12th Grade

12 Qs

Prog. no Des. de Sistemas - Classes e Objetos em python

Prog. no Des. de Sistemas - Classes e Objetos em python

12th Grade

10 Qs

Python Recursion

Python Recursion

Assessment

Quiz

Computers

12th Grade

Practice Problem

Medium

Created by

Harmeet Kaur

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Which statement about recursion in Python is TRUE?

Every recursive function must have a base case to prevent infinite recursion
Recursion always runs faster than iteration
Python has no limit on recursion depth
Recursive functions cannot return values

Answer explanation

A base case stops further recursive calls and prevents infinite recursion.

2.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Media Image

What will this code print?

3
6
9
Error

Answer explanation

factorial(3) = 3*factorial(2) = 3*2*factorial(1) = 3*2*1 = 6.

3.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

What happens if a recursive function has no base case?

It will run faster
It will return None
It will cause a RecursionError
It will exit after one call

Answer explanation

Without a base case, recursion continues until Python’s recursion limit is exceeded.

4.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Media Image

Output?

10
6
1234
Error

Answer explanation

1+2+3+4 = 10.

5.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Which of the following is NOT a good use of recursion?

Tree traversal
Factorial calculation
Processing very large loops without a base case
Fibonacci number calculation

Answer explanation

Recursive calls without a base case will cause a RecursionError.

6.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Media Image

What is the output?

2
3
5
4

Answer explanation

fib(4) = fib(3) + fib(2) = 2 + 1 = 3.

7.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

In Python, the default recursion depth limit can be checked using:

sys.getrecursionlimit()
recursion.limit()
get.limit()
sys.limit()

Answer explanation

sys.getrecursionlimit() returns the current recursion depth limit.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?