Certified Associate in Python Programming (PCAP) — Question 135

The simplest possible class definition in Python can be expressed as:

Answer options

Correct answer: B

Explanation

The correct answer, 'class X: pass', demonstrates the simplest class definition in Python, where 'pass' indicates that the class does nothing. Option A, 'class X:', is incomplete as it lacks any body. Option C, 'class X: return', is invalid syntax since 'return' cannot be used in this context. Option D, 'class X: { }', uses curly braces, which is not the correct syntax for defining classes in Python.