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?
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers