
Mastering Python Functions and Modules
Authored by Kavitha IT
English
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Define a function in Python and provide an example.
def subtract(a, b): return a - b
def multiply(a, b): return a / b
def add(a, b): return a + b
def divide(a, b): return a * b
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you call a function in Python? Give an example.
function:example()
exampleFunction[]
example_function()
callFunctionExample()
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens when you pass a list (mutable) to a function?
Modifications to the list within the function affect the original list.
The function cannot modify the list at all.
The list is converted to a string before being passed to the function.
The list is copied, and modifications do not affect the original.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain how passing a tuple (immutable) to a function works.
Passing a tuple to a function provides access to its elements without allowing modification of the original tuple.
Passing a tuple allows modification of its elements.
Tuples are converted to lists when passed to a function.
Tuples can only be passed by reference, not by value.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a lambda function? Provide a simple example.
Example: lambda x: x * 2
Example: def add(x): return x + 2
lambda function is a type of variable
lambda functions cannot take parameters
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you import a standard module in Python? Give an example.
using math as m
include math
import math
import numpy
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the dir() function in Python?
To execute a function in Python
To create a new object in Python
The purpose of the dir() function is to list the attributes and methods of an object.
To import modules in Python
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Microsoft
or continue with
%20(1).png)
Apple
Others
Already have an account?