-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions_demo.py
79 lines (55 loc) · 1.24 KB
/
functions_demo.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def function1():
print("heelo from functions!")
function1()
def function2():
return "hello from function2!"
return_from_function2 = function2()
print(return_from_function2)
def function3(s):
print("\t{}".format(s))
function3("parameter")
def function4(s1,s2):
print("{} {}".format(s1,s2))
function4("any","thing")
function4(s1="thing",s2="any")
function4(s2="thing",s1="any")
def function5(s1 = "default"):
print("{}".format(s1))
function5()
function5("anything")
def function6(s1, *more):
print("{} {}".format(s1, " ".join([s for s in more])))
function6("function6","a","b")
def function7(**ks):
for a in ks:
print(a, ks[a])
function7(a="1",b="2",c="3")
def function8(s,f,i,l):
print(type(s))
print(type(f))
print(type(i))
print(type(l))
function8("stiring", 1.0, 1, ['l','i','s','y'])
v=100
def function9():
global v #modified global var
v=200
print(v)
function9()
print(v)
def function10():
print("hello from function10")
def function11():
function10()
print("hello from function11")
function11()
def function12(x):
print(x)
if x > 0:
function12(x-1)
function12(5)
def function13(x):
while x>=0:
print(x)
x -=1
function13(5)