63.7k views
1 vote
Consider the following code segment: class Fruit : _type = "Fruit" def __init__(self, color) : self._color = color What is the name of the class variable?

User Jimmy M
by
5.2k points

1 Answer

6 votes

Answer:

_type is the correct answer for the above question

Step-by-step explanation:

  • The class variable is a variable that is defined in the class and the instance variable is defined in the constructor of the class using the self keyword.
  • The class variable is used as the static variable, but the instance variable is called by the help of objects only.
  • The above program holds only one class variable which is "_type" because it is defined in the class.
User Sanjeewa
by
5.8k points