以下是例题 (完善中)
- 完成填空,使得程序输出等于注释
python
def apply_operation(x, operation):
def inner(y):
return operation(x, y)
return inner
# hint:使用lambda表达式完成operation
add_five = apply_operation(5, _________)
print(add_five(_________))
# output:8
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
python
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def birthday(self):
self.age += 1
print(f"Happy {self.age} birthday, {self.name}!")
class Mylove(Person):
def __init__(self, person, gender):
if isinstance(person, Person):
_____.__init__(person.name, person.age)
self.gender = gender
else:
print("found the one first")
return
def _____(self):
self.age += 1
print(f"Happy {self.age} birthday, mylove \(* ~ *)/")
ta = _____("Someone", 20)
object = _____(ta, "male")
object._____
# output: Happy 21 birthday, mylove \(* ~ *)/
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
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