Practice Python Working with Functions MCQs with Answers Set 02 provided below. The MCQ Questions for [current-page:node:field_class] Working with Functions [current-page:node:field_subject] with answers and follow the latest [current-page:node:field_board]/ NCERT and KVS patterns. Refer to more Chapter-wise MCQs for [current-page:node:field_board] [current-page:node:field_class] [current-page:node:field_subject] and also download more latest study material for all subjects
MCQ for [current-page:node:field_class] [current-page:node:field_subject] Working with Functions
[current-page:node:field_class] [current-page:node:field_subject] students should review the 50 questions and answers to strengthen understanding of core concepts in Working with Functions
Working with Functions MCQ Questions [current-page:node:field_class] [current-page:node:field_subject] with Answers
Question. What will be the output of the following Python functions?
chr(‘97’)
chr(97)
(a) a Error
(b) ‘a’ a
(c) Error a
(d) Error Error
Answer: c
Explanation: The built-in function chr() returns the alphabet corresponding to the value given as an argument. This function accepts only integer type values. In the first function, we have passed a string. Hence the first function throws an error.
Question. What will be the output of the following Python function?
complex(1+2j)
(a) Error
(b) 1
(c) 2j
(d) 1+2j
Answer: d
Explanation: The built-in function complex() returns the argument in a complex form. Hence the output of the function shown above will be 1+2j.
Question. What is the output of the function complex()?
(a) 0j
(b) 0+0j
(c) 0
(d) Error
Answer: a
Explanation: The complex function returns 0j if both of the arguments are omitted, that is, if the function is in the form of complex() or complex(0), then the output will be 0j.
Question. The function divmod(a,b), where both ‘a’ and ‘b’ are integers is evaluated as:
(a) (a%b, a//b)
(b) (a//b, a%b)
(c) (a//b, a*b)
(d) (a/b, a%b)
Answer: b
Explanation: The function divmod(a,b) is evaluated as a//b, a%b, if both ‘a’ and ‘b’ are integers.
Question. What will be the output of the following Python function?
divmod(10.5,5)
divmod(2.4,1.2)
(a) (2.00, 0.50) (2.00, 0.00)
(b) (2, 0.5) (2, 0)
(c) (2.0, 0.5) (2.0, 0.0)
(d) (2, 0.5) (2)
Answer: c
Explanation: See python documentation for the function divmod.
Question. The function complex(‘2-3j’) is valid but the function complex(‘2 – 3j’) is invalid.
(a) True
(b) False
Answer: a
Explanation: When converting from a string, the string must not contain any blank spaces around the + or – operator. Hence the function complex(‘2 – 3j’) will result in an error.
Question. What will be the output of the following Python function?
list(enumerate([2, 3]))
(a) Error
(b) [(1, 2), (2, 3)]
(c) [(0, 2), (1, 3)]
(d) [(2, 3)]
Answer: c
Explanation: The built-in function enumerate() accepts an iterable as an argument. The function shown in the above case returns containing pairs of the numbers given, starting from 0. Hence the output will be: [(0, 2), (1,3)].
Question. What will be the output of the following Python functions?
x=3
eval('x^2')
(a) Error
(b) 1
(c) 9
(d) 6
Answer: b
Explanation: The function eval is use to evaluate the expression that it takes as an argument. In the above case, the eval() function is used to perform XOR operation between 3 and 2. Hence the output is 1.
Question. What will be the output of the following Python functions?
float('1e-003')
float('2e+003')
(a) 3.00 300
(b) 0.001 2000.0
(c) 0.001 200
(d) Error 2003
Answer: b
Explanation: The output of the first function will be 0.001 and that of the second function will be 2000.0. The first function created a floating point number up to 3 decimal places and the second function adds 3 zeros after the given number.
Question. Which of the following functions does not necessarily accept only iterables as arguments?
(a) enumerate()
(b) all()
(c) chr()
(d) max()
Answer: c
Explanation: The functions enumerate(), all() and max() accept iterables as arguments whereas the function chr() throws an error on receiving an iterable as an argument. Also note that the function chr() accepts only integer values.
Question. Which of the following functions accepts only integers as arguments?
(a) ord()
(b) min()
(c) chr()
(d) any()
Answer: c
Explanation: The function chr() accepts only integers as arguments. The function ord() accepts only strings. The functions min() and max() can accept floating point as well as integer arguments.
Question. Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?
(a) reverse(l)
(b) list(reverse[(l)])
(c) reversed(l)
(d) list(reversed(l))
Answer: d
Explanation: The built-in function reversed() can be used to reverse the elements of a list. This function accepts only an iterable as an argument. To print the output in the form of a list, we use: list(reversed(l)). The output will be: [4,3,2].
Question. What will be the output of the following Python function?
float(' -12345\n')
(Note that the number of blank spaces before the number is 5)
(a) -12345.0 (5 blank spaces before the number)
(b) -12345.0
(c) Error
(d) -12345.000000000…. (infinite decimal places)
Answer: b
Explanation: The function float() will remove all the blank spaces and convert the integer to a floating point number. Hence the output will be: -12345.0.
Question. What will be the output of the following Python function?
ord(65)
ord(‘A’)
(a) A 65
(b) Error 65
(c) A Error
(d) Error Error
Answer: b
Explanation: The built-in function ord() is used to return the ASCII value of the alphabet passed to it as an argument. Hence the first function results in an error and the output of the second function is 65.
Question. What will be the output of the following Python function?
float(‘-infinity’)
float(‘inf’)
(a) –inf inf
(b) –infinity inf
(c) Error Error
(d) Error Junk value
Answer: a
Explanation: The output of the first function will be –inf and that of the second function will be inf.
Question. Which of the following functions will not result in an error when no arguments are passed to it?
(a) min()
(b) divmod()
(c) all()
(d) float()
Answer: d
Explanation: The built-in functions min(), max(), divmod(), ord(), any(), all() etc throw an error when no arguments are passed to them. However there are some built-in functions like float(), complex() etc which do not throw an error when no arguments are passed to them. The output of float() is 0.0.
Question. What will be the output of the following Python function?
hex(15)
(a) f
(b) 0xF
(c) 0Xf
(d) 0xf
Answer: d
Explanation: The function hex() is used to convert the given argument into its hexadecimal representation, in lower case. Hence the output of the function hex(15) is 0xf.
Question. Which of the following functions does not throw an error?
(a) ord()
(b) ord(‘ ‘)
(c) ord(”)
(d) ord(“”)
Answer: b
Explanation: The function ord() accepts a character. Hence ord(), ord(”) and ord(“”) throw errors. However the function ord(‘ ‘) does not throw an error because in this case, we are actually passing a blank space as an argument. The output of ord(‘ ‘) is 32 (ASCII value corresponding to blank space).
Question. What will be the output of the following Python function?
len(["hello",2, 4, 6])
(a) 4
(b) 3
(c) Error
(d) 6
Answer: a
Explanation: The function len() returns the length of the number of elements in the iterable. Therefore the output of the function shown above is 4.
Question. What will be the output of the following Python function?
oct(7)
oct(‘7’)
(a) Error 07
(b) 0o7 Error
(c) 0o7 Error
(d) 07 0o7
Answer: c
Explanation: The function oct() is used to convert its argument into octal form. This function does not accept strings. Hence the second function results in an error while the output of the first function is 0o7.
Question. What is the type of each element in sys.argv?
(a) set
(b) list
(c) tuple
(d) string
Answer: d
Explanation: It is a list of strings.
Question. What is the length of sys.argv?
(a) number of arguments
(b) number of arguments + 1
(c) number of arguments – 1
(d) none of the mentioned
Answer: b
Explanation: The first argument is the name of the program itself. Therefore the length of sys.argv is one more than the number arguments.
Question. What will be the output of the following Python code?
def foo(k):
k[0] = 1
q = [0]
foo(q)
print(q)
(a) [0]
(b) [1]
(c) [1, 0]
(d) [0, 1]
Answer: b
Explanation: Lists are passed by reference.
Question. How are keyword arguments specified in the function heading?
(a) one-star followed by a valid identifier
(b) one underscore followed by a valid identifier
(c) two stars followed by a valid identifier
(d) two underscores followed by a valid identifier
Answer: c
Explanation: Refer documentation.
Question. How many keyword arguments can be passed to a function in a single function call?
(a) zero
(b) one
(c) zero or more
(d) one or more
Answer: c
Explanation: Zero keyword arguments may be passed if all the arguments have default values.
Question. What will be the output of the following Python code?
def foo(fname, val):
print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])
(a) 3 1
(b) 1 3
(c) error
(d) none of the mentioned
Answer: a
Explanation: It is possible to pass function names as arguments to other functions.
Question. What will be the output of the following Python code?
def foo():
return total + 1
total = 0
print(foo())
(a) 0
(b) 1
(c) error
(d) none of the mentioned
Answer: b
Explanation: It is possible to read the value of a global variable directly.
Question. What will be the output of the following Python code?
def foo():
total += 1
return total
total = 0
print(foo())
(a) 0
(b) 1
(c) error
(d) none of the mentioned
Answer: c
Explanation: It is not possible to change the value of a global variable without explicitly specifying it.
Question. What will be the output of the following Python code?
def foo(x):
x = ['def', 'abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
(a) True
(b) False
(c) None
(d) Error
Answer: b
Explanation: A new object is created in the function.
Question. What will be the output of the following Python code?
def foo(i, x=[]):
x.append(i)
return x
for i in range(3):
print(foo(i))
(a) [0] [1] [2]
(b) [0] [0, 1] [0, 1, 2]
(c) [1] [2] [3]
(d) [1] [1, 2] [1, 2, 3]
Answer: b
Explanation: When a list is a default value, the same list will be reused.
Question. What will be the output of the following Python code?
def foo(k):
k = [1]
q = [0]
foo(q)
print(q)
(a) [0]
(b) [1]
(c) [1, 0]
(d) [0, 1]
Answer: a
Explanation: A new list object is created in the function and the reference is lost. This can be checked by comparing the id of k before and after k = [1].
Question. How are variable length arguments specified in the function heading?
(a) one star followed by a valid identifier
(b) one underscore followed by a valid identifier
(c) two stars followed by a valid identifier
(d) two underscores followed by a valid identifier
Answer: a
Explanation: Refer documentation.
Question. Which module in the python standard library parses options received from the command line?
(a) getopt
(b) os
(c) getarg
(d) main
Answer: a
Explanation: getopt parses options received from the command line.
Question. What is the type of sys.argv?
(a) set
(b) list
(c) tuple
(d) string
Answer: b
Explanation: It is a list of elements.
Question. What is the value stored in sys.argv[0]?
(a) null
(b) you cannot access it
(c) the program’s name
(d) the first argument
Answer: c
Explanation: Refer documentation.
Question. How are default arguments specified in the function heading?
(a) identifier followed by an equal to sign and the default value
(b) identifier followed by the default value within backticks (“)
(c) identifier followed by the default value within square brackets ([])
(d) identifier
Answer: a
Explanation: Refer documentation.
Question. What will be the output of the following Python code?
def \( foo(x) \):
\( x[0] = ['def'] \)
\( x[1] = ['abc'] \)
return \( id(x) \)
\( q = ['abc', 'def'] \)
print(\( id(q) == foo(q) \))
(a) True
(b) False
(c) None
(d) Error
Answer: a Explanation: The same object is modified in the function.
Question. Where are the arguments received from the command line stored?
(a) sys.argv
(b) os.argv
(c) argv
(d) none of the mentioned
Answer: a Explanation: Refer documentation.
Question. What will be the output of the following Python code?
def \( foo(i, x=[]) \):
\( x.append(x.append(i)) \)
return \( x \)
for \( i \) in range(3):
\( y = foo(i) \)
print(\( y \))
(a) [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
(b) [[0], [[0], 1], [[0], [[0], 1], 2]]
(c) [0, None, 1, None, 2, None]
(d) [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
Answer: c Explanation: append() returns None.
Question. What will be the output of the following Python code?
def \( f1() \):
\( x=15 \)
print(\( x \))
\( x=12 \)
\( f1() \)
(a) Error
(b) 12
(c) 15
(d) 1512
Answer: c Explanation: In the code shown above, \( x=15 \) is a local variable whereas \( x=12 \) is a global variable. Preference is given to local variable over global variable. Hence the output of the code shown above is 15.
Question. What will be the output of the following Python code?
def \( f1() \):
\( x=100 \)
print(\( x \))
\( x=+1 \)
\( f1() \)
(a) Error
(b) 100
(c) 101
(d) 99
Answer: b Explanation: The variable \( x \) is a local variable. It is first printed and then modified. Hence the output of this code is 100.
Question. What will be the output of the following Python code?
def \( san(x) \):
print(\( x+1 \))
\( x=-2 \)
\( x=4 \)
san(12)
(a) 13
(b) 10
(c) 2
(d) 5
Answer: a Explanation: The value passed to the function san() is 12. This value is incremented by one and printed. Hence the output of the code shown above is 13.
Question. What will be the output of the following Python code?
def \( f1() \):
global \( x \)
\( x+=1 \)
print(\( x \))
\( x=12 \)
print("x")
(a) Error
(b) 13
(c) 13 x
(d) x
Answer: d Explanation: In the code shown above, the variable ‘x’ is declared as global within the function. Hence the output is ‘x’. Had the variable ‘x’ been a local variable, the output would have been: 13 x
Question. What will be the output of the following Python code?
def \( f1(x) \):
global \( x \)
\( x+=1 \)
print(\( x \))
f1(15)
print("hello")
(a) error
(b) hello
(c) 16
(d) 16 hello
Answer: a Explanation: The code shown above will result in an error because ‘x’ is a global variable. Had it been a local variable, the output would be: 16 hello
Question. What will be the output of the following Python code?
\( x=12 \)
def \( f1(a,b=x) \):
print(\( a,b \))
\( x=15 \)
f1(4)
(a) Error
(b) 12 4
(c) 4 12
(d) 4 15
Answer: c Explanation: At the time of leader processing, the value of ‘x’ is 12. It is not modified later. The value passed to the function f1 is 4. Hence the output of the code shown above is 4 12.
Question. What will be the output of the following Python code?
def \( f() \):
global \( a \)
print(\( a \))
\( a = \) "hello"
print(\( a \))
\( a = \) "world"
\( f() \)
print(\( a \))
(a) hello hello world
(b) world hello hello
(c) hello world world
(d) world hello world
Answer: b Explanation: Since the variable ‘a’ has been explicitly specified as a global variable, the value of a passed to the function is ‘world’. Hence the output of this code is: world hello hello
Question. What will be the output of the following Python code?
def \( f1(a,b=[]) \):
\( b.append(a) \)
return \( b \)
print(\( f1(2,[3,4]) \))
(a) [3,2,4]
(b) [2,3,4]
(c) Error
(d) [3,4,2]
Answer: d Explanation: In the code shown above, the integer 2 is appended to the list [3,4]. Hence the output of the code is [3,4,2]. Both the variables a and b are local variables.
Question. What will be the output of the following Python code?
def \( f(p, q, r) \):
global \( s \)
\( p = 10 \)
\( q = 20 \)
\( r = 30 \)
\( s = 40 \)
print(\( p,q,r,s \))
\( p,q,r,s = 1,2,3,4 \)
f(5,10,15)
(a) 1 2 3 4
(b) 5 10 15 4
(c) 10 20 30 40
(d) 5 10 15 40
Answer: c Explanation: The above code shows a combination of local and global variables. The output of this code is: 10 20 30 40
Question. What will be the output of the following Python code?
def \( f(x) \):
print("outer")
def \( f1(a) \):
print("inner")
print(\( a,x \))
f(3)
f1(1)
(a) outer error
(b) inner error
(c) outer inner
(d) error
Answer: a Explanation: The error will be caused due to the statement f1(1) because the function is nested. If f1(1) had been called inside the function, the output would have been different and there would be no error.
Question. What will be the output of the following Python code?
\( x = 5 \)
def \( f1() \):
global \( x \)
\( x = 4 \)
def \( f2(a,b) \):
global \( x \)
return \( a+b+x \)
\( f1() \)
\( total = f2(1,2) \)
print(total)
(a) Error
(b) 7
(c) 8
(d) 15
Answer: b Explanation: In the code shown above, the variable ‘x’ has been declared as a global variable under both the functions f1 and f2. The value returned is \( a+b+x = 1+2+4 = 7 \).
Question. What will be the output of the following Python code?
\( x=100 \)
def \( f1() \):
global \( x \)
\( x=90 \)
def \( f2() \):
global \( x \)
\( x=80 \)
print(\( x \))
(a) 100
(b) 90
(c) 80
(d) Error
Answer: a Explanation: The output of the code shown above is 100. This is because the variable ‘x’ has been declared as global within the functions f1 and f2.
Question. Read the following Python code carefully and point out the global variables?
\( y, z = 1, 2 \)
def \( f() \):
global \( x \)
\( x = y+z \)
(a) \( x \)
(b) \( y \) and \( z \)
(c) \( x, y \) and \( z \)
(d) Neither \( x \), nor \( y \), nor \( z \)
Answer: c Explanation: In the code shown above, \( x, y \) and \( z \) are global variables inside the function f. \( y \) and \( z \) are global because they are not assigned in the function. \( x \) is a global variable because it is explicitly specified so in the code. Hence, \( x, y \) and \( z \) are global variables.
Question. Which of the following data structures is returned by the functions globals() and locals()?
(a) list
(b) set
(c) dictionary
(d) tuple
Answer: c Explanation: Both the functions, that is, globals() and locals() return value of the data structure dictionary.
Question. What will be the output of the following Python code?
\( x=1 \ \)
def \( cg() \):
global \( x \)
\( x=x+1 \)
\( cg() \)
\( x \)
(a) 2
(b) 1
(c) 0
(d) Error
Answer: a Explanation: Since ‘x’ has been declared a global variable, it can be modified very easily within the function. Hence the output is 2.
Question. On assigning a value to a variable inside a function, it automatically becomes a global variable.
(a) True
(b) False
Answer: b Explanation: On assigning a value to a variable inside a function, it automatically becomes a local variable. Hence the above statement is false.
Question. What will be the output of the following Python code?
\( e \)= "butter"
def \( f(a) \): print(\( a \))+\( e \)
f("bitter")
(a) error
(b) butter error
(c) bitter error
(d) bitterbutter
Answer: c Explanation: The output of the code shown above will be ‘bitter’, followed by an error. The error is because the operand ‘+’ is unsupported on the types used above.
Question. What happens if a local variable exists with the same name as the global variable you want to access?
(a) Error
(b) The local variable is shadowed
(c) Undefined behavior
(d) The global variable is shadowed
Answer: d Explanation: If a local variable exists with the same name as the local variable that you want to access, then the global variable is shadowed. That is, preference is given to the local variable.
Question. What will be the output of the following Python code?
\( a=10 \)
globals()['a']=25
print(\( a \))
(a) 10
(b) 25
(c) Junk value
(d) Error
Answer: b Explanation: In the code shown above, the value of ‘a’ can be changed by using globals() function. The dictionary returned is accessed using key of the variable ‘a’ and modified to 25.
Question. ______________ returns a dictionary of the module namespace. ________________ returns a dictionary of the current namespace.
(a) locals() globals()
(b) locals() locals()
(c) globals() locals()
(d) globals() globals()
Answer: c Explanation: The function globals() returns a dictionary of the module namespace, whereas the function locals() returns a dictionary of the current namespace.
MCQs for Working with Functions [current-page:node:field_subject] [current-page:node:field_class]
Students can use these MCQs for Working with Functions to quickly test their knowledge of the chapter. These multiple-choice questions have been designed as per the latest syllabus for [current-page:node:field_class] [current-page:node:field_subject] released by [current-page:node:field_board]. Our expert teachers suggest that you should practice daily and solving these objective questions of Working with Functions to understand the important concepts and better marks in your school tests.
Working with Functions NCERT Based Objective Questions
Our expert teachers have designed these [current-page:node:field_subject] MCQs based on the official NCERT book for [current-page:node:field_class]. We have identified all questions from the most important topics that are always asked in exams. After solving these, please compare your choices with our provided answers. For better understanding of Working with Functions, you should also refer to our NCERT solutions for [current-page:node:field_class] [current-page:node:field_subject] created by our team.
Online Practice and Revision for Working with Functions [current-page:node:field_subject]
To prepare for your exams you should also take the [current-page:node:field_class] [current-page:node:field_subject] MCQ Test for this chapter on our website. This will help you improve your speed and accuracy and its also free for you. Regular revision of these [current-page:node:field_subject] topics will make you an expert in all important chapters of your course.
FAQs
You can get most exhaustive Python Working with Functions MCQs with Answers Set 02 for free on StudiesToday.com. These MCQs for are updated for the 2026-27 academic session as per examination standards.
Yes, our Python Working with Functions MCQs with Answers Set 02 include the latest type of questions, such as Assertion-Reasoning and Case-based MCQs. 50% of the paper is now competency-based.
By solving our Python Working with Functions MCQs with Answers Set 02, students can improve their accuracy and speed which is important as objective questions provide a chance to secure 100% marks in the .
Yes, MCQs for have answer key and brief explanations to help students understand logic behind the correct option as its important for 2026 competency-focused exams.
Yes, you can also access online interactive tests for Python Working with Functions MCQs with Answers Set 02 on StudiesToday.com as they provide instant answers and score to help you track your progress in .