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
Empty file added LAB_OOP_10
Empty file.
Binary file added __pycache__/panda.cpython-312.pyc
Binary file not shown.
23 changes: 23 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from panda import Panda

# Create 4 objects
panda1 = Panda("Po", 5, "Black & White", 100)
panda2 = Panda("Luna", 3, "Black & White", 80)
panda3 = Panda("Milo", 7, "Black & White", 120)
panda4 = Panda("Bella", 4, "Black & White", 90)

# Print 1 attribute value
print(panda1.name)

# Call methods on each object
panda1.eat()
panda1.sleep()

panda2.eat()
panda2.sleep()

panda3.eat()
panda3.sleep()

panda4.eat()
panda4.sleep()
15 changes: 15 additions & 0 deletions panda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Panda:
# Constructor
def __init__(self, name, age, color, weight):
self.name = name
self.age = age
self.color = color
self.weight = weight

# Method 1
def eat(self):
print(f"{self.name} is eating bamboo 🌿")

# Method 2
def sleep(self):
print(f"{self.name} is sleeping 😴")