Recursion in Python Quiz

Recursion in Python Quiz

9th Grade

14 Qs

quiz-placeholder

Similar activities

Review loops

Review loops

8th Grade - University

12 Qs

Fundamentos de Programación en Python

Fundamentos de Programación en Python

6th Grade - University

10 Qs

Тест з теми 'Списки – змінювані послідовності'

Тест з теми 'Списки – змінювані послідовності'

7th Grade - University

12 Qs

Тест по функциям Python (functions 3)

Тест по функциям Python (functions 3)

9th - 12th Grade

18 Qs

Module 3 - Unity Scripting Basics

Module 3 - Unity Scripting Basics

9th - 12th Grade

15 Qs

Python for loop/lists

Python for loop/lists

9th Grade - University

15 Qs

Python Battle Royale: Who Will Survive in the End?❤️🤔

Python Battle Royale: Who Will Survive in the End?❤️🤔

9th - 12th Grade

15 Qs

Увлекательный мир Python

Увлекательный мир Python

6th Grade - University

9 Qs

Recursion in Python Quiz

Recursion in Python Quiz

Assessment

Quiz

Information Technology (IT)

9th Grade

Easy

Created by

Fadi Fadi

Used 1+ times

FREE Resource

14 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is recursion in Python?

A way to create loops using for

A function that returns a list

A function that calls itself

A function that runs forever

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main danger of recursion if not written properly?

It prints the wrong result

It runs only once

It causes an infinite loop

It turns into a list

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which part of a recursive function stops it from calling itself forever?

Return statement

Loop

Base case

Recursive call

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will this function return? def factorial(n): if n == 1: return 1 else: return n * factorial(n - 1) print(factorial(3))

3

6

9

Error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the base case in this function? def countdown(n): if n == 0: print("Blast off!") else: print(n) countdown(n - 1)

print(n)

n == 0

countdown(n - 1)

"Blast off!"

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is printed when this code runs? def test(x): if x == 0: return print(x) test(x - 1) test(3)

3 2 1 0

0 1 2 3

3 2 1

Nothing

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these problems is most suitable for recursion?

Printing numbers from 1 to 10

Finding maximum in a list

Searching a file in nested folders

Adding two numbers

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?