Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/panda.cpython-313.pyc
Binary file not shown.
20 changes: 20 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from panda import Panda
def main():
pandas = []
p1 = Panda("P1", 5, "Forest")
p2 = Panda("P2", 3, "Zoo", "sad")
p3 = Panda("P3", 7, "Nature", "happy")
p4 = Panda("P3", 2, "Wild", "playful")
pandas.append(p1)
pandas.append(p2)
pandas.append(p3)
pandas.append(p4)
for panda in pandas:
print(f"++++++++ Meet {panda.name} ++++++++")
panda.eat()
panda.play()
panda.sleep()
print(panda)

if __name__ == "__main__":
main()
16 changes: 16 additions & 0 deletions panda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Panda:
def __init__(self, name, age, location, mood="okay"):
self.name = name
self.age = age
self.location = location
self.mood = mood
def eat(self):
print(f"{self.name} is {self.mood} and eating bamboo.")
def sleep(self):
print(f"{self.name} is sleeping. and will wake up in a better mood.")
self.mood = "relaxed"
def play(self):
print(f"{self.name} in {self.mood} mood, and is playing and having fun.")
self.mood = "excited"
def __str__(self):
return f"Panda Info:-\n\nName: {self.name}\nAge: {self.age}\nLocation: {self.location}\nMood: {self.mood}\n"