Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code? def f(x): def f1(*args, **kwargs): print("*"* 5) x(*args, **kwargs) print("*"* 5) return f1 def a(x): def f1(*args, **kwargs): print("%"* 5) x(*args, **kwargs) print("%"* 5) return f1 @f @a def p(m): print(m) p("hello")
Q2
A function with parameters cannot be decorated.
Q3
What will be the output of the following Python code snippet? X=”hi” print(“05d”%X)
Q4
What will be the output of the following Python expression if X = -122? print("-%06d"%x)
Q5
What is the purpose of the @classmethod decorator compared to the @staticmethod decorator?
Q6
Which loop in Python is ideal for situations where you don't know the number of iterations?
Q7
What will be the output of the following Python expression if x=456? print("%-06d"%x)
Q8
The output of the two codes shown below is the same. i. bin((2**16)-1) ii. '{}'.format(bin((2**16)-1))
Q9
What will be the output of the following Python code? 'The {} side {1} {2}'.format('bright', 'of', 'life')
Q10
In Python, what does the expression {:#x} do in a formatted string?
Q11
What will be the output of the following Python code? def f(x): def f1(*args, **kwargs): print("*", 5) x(*args, **kwargs) print("*", 5) return f1 @f def p(m): p(m) print("hello")
Q12
The output of which of the codes shown below will be: "There are 4 blue birds."?
Q13
What will be the output of the following Python code snippet? '%d %s %g you' %(1, 'hello', 4.0)
Q14
Which symbol is used to denote a decorator in Python syntax?
Q15
What is the primary purpose of the functools.partial function in Python?
Q16
Which of the following is used to format a string with left-aligned text within a field?
Q17
Which format specifier is used to represent an integer in binary form in a formatted string?
Q18
What will be the output of the following Python code? '{0:.2f}'.format(1.234)
Q19
Which decorator is used to cache the results of a function call in Python?
Q20
What will be the output of the following Python code? '%s' %((1.23,),)
Q21
Which of the following is a correct way to define a decorator function in Python?
Q22
What will be the output of the following Python expression if x=56.236? print("%.2f"%x)
Q23
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()
Q24
What is the output of the code: print("{:.2f}".format(3.14159))?
Q25
What will be the output of the following Python code snippet? a='hello' q=10 vars()