Bird
0
0

Given this code, what will be printed?

hard📝 Application Q15 of 15
Python - Methods and Behavior Definition
Given this code, what will be printed?
class C:
    def a(self):
        print('A')
        self.b()
    def b(self):
        print('B')
        self.c()
    def c(self):
        print('C')

c = C()
c.a()
AA\nB\nC
BA\nC\nB
CC\nB\nA
DB\nC\nA
Step-by-Step Solution
Solution:
  1. Step 1: Follow method calls starting from c.a()

    c.a() prints 'A' then calls self.b()
  2. Step 2: Trace self.b() and self.c()

    self.b() prints 'B' then calls self.c(), which prints 'C'.
  3. Step 3: Combine outputs in order

    Output is 'A' then 'B' then 'C' each on new lines.
  4. Final Answer:

    A\nB\nC -> Option A
  5. Quick Check:

    Method calls chain in order a->b->c [OK]
Quick Trick: Follow each method call in order to find print sequence [OK]
Common Mistakes:
  • Mixing order of method calls
  • Skipping intermediate method calls
  • Assuming methods run independently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes