Question: what is the difference between class and def in python?
Answer: 2 Answers. class is used to define a class (a template from which you can instantiate objects). def is used to define a function or a method. A method is like a function that belongs to a class.