PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

Quiz
•
Computers
•
University
•
Hard
MS.SHYAMALADEVI C
Used 3+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a recursive function in Python?
A function that calls itself
A function that returns a Boolean value
A function that performs mathematical operations
A function that has multiple return values
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet?
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
print(factorial(5))
1
5
10
120
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the "return" statement in a function?
To end the execution of a function
To return a value from a function
To print output from a function
To define a local variable within a function
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the "return" statement in a function?
To end the execution of a function
To return a value from a function
To print output from a function
To define a local variable within a function
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the scope of a variable defined inside a function?
Global scope
Local scope within the function
Both global and local scope
It is not possible to define variables inside a function
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the base case in a recursive function?
The initial condition that ends the recursion
The final output of the recursive function
The maximum number of recursive calls allowed
The condition for starting the recursion
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet?
def countdown(n):
if n <= 0:
return
print(n)
countdown(n-1)
countdown(5)
5 4 3 2 1
1 2 3 4 5
0
Error
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
Python Basics

Quiz
•
12th Grade - University
10 questions
FCP Series 4

Quiz
•
University
20 questions
BS TEST2

Quiz
•
University
10 questions
Analysis of Algorithms

Quiz
•
University
12 questions
Functions C

Quiz
•
University
10 questions
TIU Quiz-9

Quiz
•
University
20 questions
C Programming Unit-1 Test-2

Quiz
•
University
17 questions
Asymptotic complexity

Quiz
•
University
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade