more function examples
This commit is contained in:
parent
f9bcfbe07a
commit
5731c0e015
14
function.10.py
Normal file
14
function.10.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
def foo():
|
||||
print('foo')
|
||||
|
||||
def bar():
|
||||
print('bar')
|
||||
|
||||
def tar():
|
||||
print('tar')
|
||||
|
||||
d = {1: foo, 2: bar, 3: tar}
|
||||
|
||||
d[1]()
|
||||
d[2]()
|
||||
d[3]()
|
14
function.9.py
Normal file
14
function.9.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
def foo():
|
||||
print('foo')
|
||||
|
||||
def bar():
|
||||
print('bar')
|
||||
|
||||
def tar():
|
||||
print('tar')
|
||||
|
||||
a = [foo, bar, tar]
|
||||
|
||||
for f in a:
|
||||
f()
|
||||
|
Loading…
Reference in New Issue
Block a user