What is the output of the following Python code?

class P:
    def f(self):
        return self.g()

    def g(self):
        return 'P'

class C(P):
    def g(self):
        return 'C'

p = P()
c = C()
print(p.f(), c.f())
print(p.g(), c.g())

 

P C P C
P P C
P P P C
Error in first print statement as method f() is not defined in C class
Verified Answer
Correct Option - a

To get all Infosys Certified Python Programmer Exam questions Join Telegram Group https://rebrand.ly/lex-group-70b557

Telegram

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in

Updated on Fri, 22 Aug 2025