diff --git a/__pycache__/panda.cpython-314.pyc b/__pycache__/panda.cpython-314.pyc new file mode 100644 index 0000000..ae91394 Binary files /dev/null and b/__pycache__/panda.cpython-314.pyc differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..d31b937 --- /dev/null +++ b/main.py @@ -0,0 +1,15 @@ +from panda import Panda + +panda1 = Panda("Ling", "Giant Panda", "male", 5) +panda2 = Panda("Mei", "Red Panda", "female", 3) +panda3 = Panda("Bao", "Giant Panda", "male", 2) +panda4 = Panda("Xiao", "Red Panda", "female", 4) + +pandas = [panda1, panda2, panda3, panda4] + +for panda in pandas: + print(f" Name: {panda.name}, Type: {panda.type}, Sex: {panda.sex}, Age: {panda.age}") + print(panda.eat()) + print(panda.sleep()) + print("-" * 30) + diff --git a/panda.py b/panda.py new file mode 100644 index 0000000..5a712ed --- /dev/null +++ b/panda.py @@ -0,0 +1,11 @@ +class Panda: + def __init__(self, name, type, sex, age): + self.name = name + self.type = type + self.sex = sex + self.age = age + + def eat(self): + return f"{self.name} is eating bamboo." + def sleep(self): + return f"{self.name} is sleeping." \ No newline at end of file