Python Practice › OOP Programs › Program 47

Animal class

EasyOOP Programs · 47 of 48

Create Animal with name and colour and a method to print them.

Advertisement
Output
Bruno is brown

Approach

  1. Store and print.

Solution

Python
class Animal:    def __init__(self, name, color):        self.name, self.color = name, color     def show(self):        print(f"{self.name} is {self.color}") Animal("Bruno", "brown").show()
Output
Bruno is brown
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More oop programs

← All 48 OOP Programs