Python Programming (2180711) MCQs

MCQs of Functions, Scoping and Abstraction

Showing 1 to 0 out of 10 Questions
1.
Why are local variable names beginning with an underscore discouraged?
(a) they are used to indicate a private variable of a class
(b) they confuse the interpreter
(c) they are used to indicate global variables
(d) they slow down execution
Answer:

Option (a)

2.
Which of the following is not a keyword?
(a) eval
(b) assert
(c) nonlocal
(d) pass
Answer:

Option (a)

3.
All keywords in Python are in _________
(a) lower case
(b) UPPER CASE
(c) Capitalized
(d) None of the mentioned
Answer:

Option (d)

4.
Given a function that does not return any value, What value is thrown by default when executed in shell.
(a) int
(b) bool
(c) void
(d) None
Answer:

Option (d)

5.
What is the return type of function id?
(a) int
(b) float
(c) bool
(d) dict
Answer:

Option (a)

6.
To find the decimal value of 1111, that is 15, we can use the function
(a) int(1111,10)
(b) int(‘1111’,10)
(c) int(1111,2)
(d) int(‘1111’,2)
Answer:

Option (d)

7.
In the following Python code, which function is the decorator? def mk(x): def mk1(): print(""Decorated"") x() return mk1 def mk2(): print(""Ordinary"") p = mk(mk2) p()
(a) p()
(b) mk()
(c) mk1()
(d) mk2()
Answer:

Option (b)

8.
The ______ symbol along with the name of the decorator function can be placed above the definition of the function to be decorated works as an alternate way for decorating a function.
(a) #
(b) $
(c) @
(d) &
Answer:

Option (c)

9.
What will be the output of the following Python function? def f(p, q): return p%q f(0, 2) f(2, 0)
(a) 0 0
(b) Zero Division Error Zero Division Error
(c) 0 Zero Division Error
(d) Zero Division Error 0
Answer:

Option (c)

10.
A function with parameters cannot be decorated.
(a) TRUE
(b) FALSE
Answer:

Option (a)

Showing 1 to 0 out of 10 Questions