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