-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass2.py
More file actions
44 lines (30 loc) · 941 Bytes
/
Copy pathclass2.py
File metadata and controls
44 lines (30 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 3 16:23:27 2026
@author: salehi
"""
class Animal:
def __init__(self, name, species, age, sound):
self.name = name
self.species = species
self.age = age
self.sound = sound
self.zoo_name = "eram"
def make_sound(self):
print(self.sound)
def info(self):
print(self.name, self.age, self.species, self.sound)
def __str__(self):
return f"{self.name},{self.species},{self.age},{self.sound}"
anim = Animal("shir", "vahshi", 5, "ghoresh")
anim.make_sound()
anim.info()
class Bird(Animal):
def __init__(self, name, species, age, sound, win_span):
Animal.__init__(self, name, species, age, sound)
self.win_span = win_span
def make_sound(self):
print(f"sedayeh parandeh{self.sound}")
anim2 = Bird("kabootar", "parandeh", 4, "hoho", 2)
anim2.make_sound()
print(str(anim2))