Questions: How many attribute(s) does the following student class has? ``` 1 class Student: campus = 'Main' def init(self, name): self.name = name def intro(self): print('I am .'.format(self.name)) ```

How many attribute(s) does the following student class has?
```
1 class Student:
    campus = 'Main'
    def init(self, name):
        self.name = name
    def intro(self):
        print('I am .'.format(self.name))
```
Transcript text: How many attribute(s) does the following student class has? ``` 1 class Student: campus = 'Main' def __init__(self, name): self.name = name def intro(self): print('I am {}.'.format(self.name)) ```
failed

Solution

failed
failed

Solution Steps

Step 1: Identify Class Attributes

Class attributes are defined outside any methods and are shared by all instances of the class. In this case, campus = 'Main' is a class attribute.

Step 2: Identify Instance Attributes

Instance attributes are defined within the __init__ method using self.attribute_name. These are specific to each instance of the class. Here, self.name = name creates an instance attribute called name.

Final Answer:

The Student class has two attributes: one class attribute (campus) and one instance attribute (name).

Was this solution helpful?
failed
Unhelpful
failed
Helpful