365,617 views
33 votes
33 votes
What does it mean when a class has an argument python?.

User SeriousDron
by
2.8k points

1 Answer

12 votes
12 votes

Answer:

Objects of a class can optionally accept arguments. These arguments are used to set values within an object. Consider the following code: class Employee: def __init__(self, name) self.name = name The __init__method lets us assign a value for the “self.name” variable in our class. We can reference this variable in any method in our class.

Step-by-step explanation:

User Mehul Mistri
by
3.0k points