Q:

How to create an empty class in Python?

0

How to create an empty class in Python?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

An empty class is a class that does not have any code defined within its block. In Python, we create an empty class by the keyword “pass”. The pass is a special statement in Python that does nothing. It only works as a dummy statement. However, objects of an empty class can also be created.

# Python program to demonstrate 
# empty class 
class Aticleworld: 
  pass
# Driver's code 
obj = Aticleworld() 
print(obj) 

Output:

__main__.Aticleworld object at 0x7fcc56a0d518>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Interview Questions and Answers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Explain Inheritance in Python with an example?... >>
<< What is the syntax for creating an instance of a c...