-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassDog.py
More file actions
32 lines (21 loc) · 695 Bytes
/
ClassDog.py
File metadata and controls
32 lines (21 loc) · 695 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
# Online Python - IDE, Editor, Compiler, Interpreter
class Dog:
def __init__(self, species, name, age):
self.species = "Canis familiaris"
self.name = name
self.age = age
def __str__(self):
return f"{self.species}{self.name}({self.age})"
def speak(self,sound):
def wrapper():
if 5 <= len(sound) < 15:
print(sound)
return sound
else:
pass
return wrapper
def say_woof():
print("Woof")
d1 = Dog ("Canis familaris", "Zippy", 7)
d1.speak(say_woof)
print (d1)