0
Please help with Creating class cats with public members: cats name and age are required? In python
So my specification is 1. Add _init_() method of the class that initialise string member variables to empty string and numeric value to 0. 2. Add method populate () to the class. The method is used to assign a value to the member variable of the class. 3. Add the method display () to the class. The method is used to display the member variable of the class. Prompt the user for input to demonstrate the use of the Cats class. You are welcome to enhance that last definition with additional attributes.
5 Réponses
+ 3
We would like to see your attempt first.
+ 1
here is my attempts but i dnt knw wht m going wrong
class cats():
def _init_(self,name, age):
self.name=name
self.name=age
def populate(self):
self.name=name
self.age=age
def display(self):
print(self.name)
cats1= cats(kitty, 10)
cats1=display()
+ 1
Kitty is a string, supposed to be in quotes""
0
The first function is supposed to be __init__ (2 underscores)
0
class Cats:
def __init__(self,name, age):
self.name=name
self.age=age
def display(self):
print(self.name)
cats1= Cats("kitty", 10)
cats1.display()