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.

9th Apr 2020, 2:14 PM
mahlatse Ignatious magongoa
mahlatse Ignatious magongoa - avatar
5 Antworten
+ 3
We would like to see your attempt first.
9th Apr 2020, 2:15 PM
HonFu
HonFu - avatar
+ 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()
9th Apr 2020, 2:30 PM
mahlatse Ignatious magongoa
mahlatse Ignatious magongoa - avatar
+ 1
Kitty is a string, supposed to be in quotes""
9th Apr 2020, 3:14 PM
Justus
Justus - avatar
0
The first function is supposed to be __init__ (2 underscores)
9th Apr 2020, 3:13 PM
Justus
Justus - avatar
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()
9th Apr 2020, 3:15 PM
Justus
Justus - avatar