Font size
Worksheetsfunctions in python class 12 vaishali
Total questions: 50
Worksheet time: 29mins
What term is used to describe data passed into a function?
Variable
Loop
Constant
Parameter
Leo wants to create a function that will roll a dice. Which is the correct function definition header?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
__________ keyword is used for creating a function in Python.
define
fun
def
function
What is the output of the given code?
10 20 10
10
20
10 20
What is the output of the given code?
10 20 10 20
10 20 10
10 20 20
Error
Python supports variable number of parameters.
True
False
Function header in Python contains _________________.
function name
list of parameters
return type
all the above
Only A & B
The default return value of any function in Python is _______________.
null
0
None
Garbage value
__________ is the built-in function to know the type of a variable or function.
id()
type()
data_type()
none of the above
times is ________________ type of argument.
default arguments
keyword arguments
positional arguments
arbitrary positional arguments
arbitrary keyword arguments
Select the advantages of functions
Modular programming
Code re-usability
Improving clarity of the code
All the above
Which of the following is the use of id() function in python?
Id returns the identity of the object
Every object doesn’t have a unique id
All of the mentioned
None of the mentioned
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
Write the line of code that will call the function.
(a)
Write the line of code that will define the function, draw_coin
(a)
Do you call or define a function first?
call
define
Rewrite this line of code correctly!
(a)
Rewrite this line of code correctly!
(a)
In the code given, a function was defined. Now write the code to call the function.
(a)
Rewrite the line of code that is written incorrectly to make it correct!
Hint: The mistake is when the function gets called
(a)
A variable that can be accessed from anywhere in a program is called
(a)
Which keyword marks the beginning of the function block
Func
Define
def
Function
What will be the output of this program?
def addOne(number):
number += 1
return number
one = addOne(0)
two = addOne(one)
print(two)
0
1
2
3
4
What will be the output of this program?
def hello():
print(“I am a beginner”)
hello()
hello()
I am a beginner
I am a beginner I am a beginner
Hello
Hello
Hello
I am a beginner
I am a beginner
When a variable is inside of a function what do you call its scope?
Static
Local
Global
Boolean
What is the purpose of a function?
They are reusable pieces of programs.
They are required by the Python
They allow us to compile our program
They make the program larger
What is the default return value of a function that does not return any value explicitly?
Int
Float
Double
None
What does the function header contain?
The function name
The function name and parameter list
The parameter list
The return value
The output of the code above will be
0
1
99
What are the two main types of functions?
Custom function
Built-in function & User defined function
User function
System function
What will be the output of the following Python code?
def cube(x):
return x * x * x
x = cube(3)
print (x)
9
3
27
30
What is a variable defined inside a function referred to as?
A global variable
A volatile variable
A local variable
An automatic variable
What is the output of the below program?
x is 50Changed global x to 2Value of x is 50
x is 50Changed global x to 2Value of x is 2
x is 50Changed global x to 50Value of x is 50
None of the mentioned
What is the output of the function shown below (random module has already been imported)?
random.choice('sun')
sun
either s,u or n
u
Error
Which of the following function headers is correct?*
def fun(a = 2, b = 3, c)
def fun(a = 2, b, c = 3)
def fun(a, b = 2, c = 3)
def fun(a, b, c = 3, d)
Which of the following functions is a built-in function in python?
array()
sqrt()
factorial()
print()
What will be the output of the following Python expression? round(4.576)
4.5
5
4
4.6
A Python module is a file with the _____ file extension that contains valid Python code.
.pym
.pymodule
.module
.py
What is returned by math.ceil(3.4)?
3
4
4.0
3.0
Which statement is correct to import all modules from the package
from package import all
from package import *
from package include all
from package include *
4. The code block of function always comes after a _______.
;
:
'
#
What term is used to describe data passed into a function?
Variable
Loop
Constant
Parameter
Select the advantages of functions
Modular programming
Code re-usability
Improving clarity of the code
All the above
