Vidyalelo
Python · all questions

Formatting and Decorators
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

82

Questions

3/5

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Python code?
D=dict(p='Exam', q='Veda')
'{p}{q}'.format(**D)

Select an option to see the answer and solution.

What will be the output of the following Python code?
'{a}{b}{a}'.format(a='hello', b='world')

Select an option to see the answer and solution.

In Python, what is the role of the @functools.lru_cache decorator?

Select an option to see the answer and solution.

What is the purpose of a decorator in Python?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x=3.3456789
'%f | %e | %g' %(x, x, x)

Select an option to see the answer and solution.

Which of the following formatting options can be used in order to add 'n' blank spaces after a given string 'S'?

Select an option to see the answer and solution.

What will be the output of the following Python code?
s='%s, %s & %s'
s%('mumbai', 'kolkata', 'delhi')

Select an option to see the answer and solution.

In Python, what is the primary use of the super() function in a subclass constructor?

Select an option to see the answer and solution.

In Python, what is the purpose of the @property decorator?

Select an option to see the answer and solution.

What will be the output of the following Python code?
def ordi():
	print("Ordinary")
ordi
ordi()

Select an option to see the answer and solution.

What will be the output of the following Python code?
hex(255), int('FF', 16), 0xFF

Select an option to see the answer and solution.

What is the primary use of the @final decorator in Python?

Select an option to see the answer and solution.

What will be the output of the following Python code?
'%.2f%s' % (1.2345, 99)

Select an option to see the answer and solution.

What is the role of the @abstractmethod decorator in Python?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
'%(qty)d more %(food)s' %{'qty':1, 'food': 'spam'}

Select an option to see the answer and solution.

What does the * symbol do when used in a function's parameter list?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
X=”Exam-Veda”
print(“%56s”,X)

Select an option to see the answer and solution.

What will be the output of the following Python function?
def f(p, q):
	return p%q
f(0, 2)
f(2, 0)

Select an option to see the answer and solution.

What is the output of the code: print("{:.2f}".format(3.14159))?

Select an option to see the answer and solution.

What will be the output of the following Python expression if x=56.236?
print("%.2f"%x)

Select an option to see the answer and solution.