PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

University

15 Qs

quiz-placeholder

Similar activities

Java Method

Java Method

University

15 Qs

Python Programming Basics

Python Programming Basics

University

14 Qs

Alabi, Kolade, CSCI-2380-01P, PRE

Alabi, Kolade, CSCI-2380-01P, PRE

University

15 Qs

python functions

python functions

University

14 Qs

9618 Chp11 Programming Basics Quiz

9618 Chp11 Programming Basics Quiz

11th Grade - University

20 Qs

QUIZ 1 DS1E

QUIZ 1 DS1E

University

10 Qs

002_Java Methods

002_Java Methods

12th Grade - University

15 Qs

Chapter 9 Computing II

Chapter 9 Computing II

University

13 Qs

PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

Assessment

Quiz

Computers

University

Hard

Created by

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

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?