PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

University

15 Qs

quiz-placeholder

Similar activities

002_Java Methods

002_Java Methods

12th Grade - University

15 Qs

PROGRAMMING IN PYTHON - UNIT II - TEST 1 MCQS

PROGRAMMING IN PYTHON - UNIT II - TEST 1 MCQS

University

15 Qs

JavaScript

JavaScript

University

15 Qs

CSE 102 Exam 3 Practice

CSE 102 Exam 3 Practice

University

18 Qs

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

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

University

15 Qs

Java Programming

Java Programming

University

20 Qs

C programming syntax quiz

C programming syntax quiz

University

20 Qs

Exam 1 Practice

Exam 1 Practice

University

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