Skip to main content

Formatting And Decorators — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Formatting And Decorators — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

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

Question 2 of 40
★ FPSC ★ PPSC

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

Question 3 of 40
★ FPSC ★ PPSC

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

Question 4 of 40
★ FPSC ★ PPSC

What is the purpose of a decorator in Python?

Question 5 of 40
★ FPSC ★ PPSC

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

Question 6 of 40
★ FPSC ★ PPSC

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

Question 7 of 40
★ FPSC ★ PPSC

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

Question 8 of 40
★ FPSC ★ PPSC

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

Question 9 of 40
★ FPSC ★ PPSC

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

Question 10 of 40
★ FPSC ★ PPSC

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

Question 11 of 40
★ FPSC ★ PPSC

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

Question 12 of 40
★ FPSC ★ PPSC

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

Question 13 of 40
★ FPSC ★ PPSC

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

Question 14 of 40
★ FPSC ★ PPSC

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

Question 15 of 40
★ FPSC ★ PPSC

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

Question 16 of 40
★ FPSC ★ PPSC

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

Question 17 of 40
★ FPSC ★ PPSC

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

Question 18 of 40
★ FPSC ★ PPSC

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

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? X=”hi” print(“05d”%X)

Question 20 of 40
★ FPSC ★ PPSC

A function with parameters cannot be decorated.

Question 21 of 40
★ FPSC ★ PPSC

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()

Question 22 of 40
★ FPSC ★ PPSC

The output of which of the codes shown below will be: "There are 4 blue birds."?

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? '%d %s %g you' %(1, 'hello', 4.0)

Question 24 of 40
★ FPSC ★ PPSC

What is the purpose of the @classmethod decorator compared to the @staticmethod decorator?

Question 25 of 40
★ FPSC ★ PPSC

The output of the two codes shown below is the same. i. bin((2**16)-1) ii. '{}'.format(bin((2**16)-1))

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? '{0:.2f}'.format(1.234)

Question 27 of 40
★ FPSC ★ PPSC

Which symbol is used to denote a decorator in Python syntax?

Question 28 of 40
★ FPSC ★ PPSC

Which decorator is used to cache the results of a function call in Python?

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? '%s' %((1.23,),)

Question 30 of 40
★ FPSC ★ PPSC

What is the primary purpose of the functools.partial function in Python?

Question 31 of 40
★ FPSC ★ PPSC

Which of the following is used to format a string with left-aligned text within a field?

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python expression if x=456? print("%-06d"%x)

Question 33 of 40
★ FPSC ★ PPSC

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")

Question 34 of 40
★ FPSC ★ PPSC

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")

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? 'The {} side {1} {2}'.format('bright', 'of', 'life')

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? a='hello' q=10 vars()

Question 37 of 40
★ FPSC ★ PPSC

In Python, what does the expression {:#x} do in a formatted string?

Question 38 of 40
★ FPSC ★ PPSC

Which format specifier is used to represent an integer in binary form in a formatted string?

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following Python expression if X = -122? print("-%06d"%x)

Question 40 of 40
★ FPSC ★ PPSC

Which of the following is a correct way to define a decorator function in Python?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →