initial creation
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
def fun_one(): # <1>
|
||||
print("Hello, world")
|
||||
|
||||
|
||||
print("fun_one():", end=' ')
|
||||
fun_one()
|
||||
print()
|
||||
|
||||
|
||||
def fun_two(n): # <2>
|
||||
return n ** 2
|
||||
|
||||
|
||||
x = fun_two(5)
|
||||
print("fun_two(5) is {}\n".format(x))
|
||||
|
||||
|
||||
def fun_three(count=3): # <3>
|
||||
for _ in range(count):
|
||||
print("spam", end=' ')
|
||||
print()
|
||||
|
||||
|
||||
fun_three()
|
||||
fun_three(10)
|
||||
print()
|
||||
|
||||
|
||||
def fun_four(n, *opt): # <4>
|
||||
print("fun_four():")
|
||||
print("n is ", n)
|
||||
print("opt is", opt)
|
||||
print('-' * 20)
|
||||
|
||||
|
||||
fun_four('apple')
|
||||
fun_four('apple', "blueberry", "peach", "cherry")
|
||||
|
||||
|
||||
def fun_five(*, spam=0, eggs=0): # <5>
|
||||
print("fun_five():")
|
||||
print("spam is:", spam)
|
||||
print("eggs is:", eggs)
|
||||
print()
|
||||
|
||||
|
||||
fun_five(spam=1, eggs=2)
|
||||
fun_five(eggs=2, spam=2)
|
||||
fun_five(spam=1)
|
||||
fun_five(eggs=2)
|
||||
fun_five()
|
||||
|
||||
|
||||
def fun_six(**named_args): # <6>
|
||||
print("fun_six():")
|
||||
for name in named_args:
|
||||
print(name, "==> ", named_args[name])
|
||||
|
||||
|
||||
fun_six(name="Lancelot", quest="Grail", color="red")
|
||||
Reference in New Issue
Block a user