Python Recursion

Python Recursion

12th Grade

10 Qs

quiz-placeholder

Similar activities

History of Computers

History of Computers

6th - 12th Grade

15 Qs

Grade 12-Python selection&iteration

Grade 12-Python selection&iteration

11th - 12th Grade

15 Qs

Python Fundamentals and Programming

Python Fundamentals and Programming

11th - 12th Grade

13 Qs

Quiz 1

Quiz 1

11th - 12th Grade

10 Qs

Khởi động

Khởi động

9th - 12th Grade

10 Qs

Ôn tập chủ đề 5. Giải quyết vấn đề với sự trợ giúp của máy tính

Ôn tập chủ đề 5. Giải quyết vấn đề với sự trợ giúp của máy tính

12th Grade

10 Qs

CO - 1 Quiz - 1-DB_Python Basic

CO - 1 Quiz - 1-DB_Python Basic

10th Grade - University

15 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?