Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 39)
39.
Consider the following Python code:
class Animal:
    def __init__(self, species):
        self.species = species

class Bird(Animal):
    def __init__(self, species, wingspan):
        super().__init__(species)
        self.wingspan = wingspan

# Create an instance of the Bird class
my_bird = Bird("Eagle", 2.5)

# Access and print attributes
print(my_bird.species)
print(my_bird.wingspan)
What will be the output of the code?
Eagle \n 2.5
2.5 \n Eagle
Eagle
2.5
Answer: Option
Explanation:
The code creates an instance of the `Bird` class and prints the values of its attributes (`species`, `wingspan`).
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.