What are attributes and methods in a python class?
Answer / Piyush Gupta
In Python, attributes represent data members or variables associated with an object of a class. Methods are functions that are bound to objects of a class. They perform actions on the data stored in the attributes.nExample of class definition:n```pythonnclass MyClass:n def __init__(self, attr1, attr2):n self.attr1 = attr1n self.attr2 = attr2n def my_method(self):n return self.attr1 + self.attr2n```
| Is This Answer Correct ? | 0 Yes | 0 No |
How do I sleep in python?
When you need ordered container of things, which will be manipulated, use lists?
What does “list comprehension” mean? How does it work and how can I use it?
Does flask work with python 3?
What is python mapping?
Which python library is built on top of matplotlib and pandas to ease data plotting?
What is a numpy array?
What are the built-in data-types in python?
What is the dictionary?
Is javascript harder than python?
What is python explain the advantages of using python?
What is a metaclass in Python?