Search Header Logo

Python Functions and Modules Quiz

Authored by Dr. Deepti Sharma

Computers

University

Python Functions and Modules Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? python Copy code def func(a, b=5): return a + b print(func(3))

None

Error

5

3

8

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following allows a function to accept a variable number of keyword arguments?

**kwargs

**variables

*args

kwargs[]

*variables

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output? python Copy code def func(): return "Hello", "World" result = func() print(type(result))

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which statement about Python functions is false?

Functions can accept keyword arguments.

Functions can have default arguments.

Functions can be nested.

Functions can return multiple values as tuples.

Functions must return a value.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? python Copy code def func(x, y): x = x + y return x print(func("Hello", "World"))

HelloWorld

Hello World

Error

None

Hello-World

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? python Copy code def add(a, b=10): return a + b print(add(5))

None

15

5

Error

10

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the *args in a function definition?

It allows the function to accept any number of non-keyword arguments.

It allows the function to accept a fixed number of arguments.

It allows the function to accept any number of keyword arguments.

It is used for returning multiple values from a function.

It helps to create default parameters in the function.

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?

Discover more resources for Computers