-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
110 lines (87 loc) · 1.39 KB
/
function.py
File metadata and controls
110 lines (87 loc) · 1.39 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'''
Created on
Course work:
@author: Elakia VM
Source:
'''
"""
Creating the function
"""
def func():
print("hello world")
"""
Calling the a function
"""
def func():
print("this is function calling program")
func()
"""
Arguments
"""
def value(text):
print("name " + text)
value("ram")
value("raji")
value("sara")
"""
Using **kwargs
"""
def value(**val):
print("name " + val["lname"])
value(fname = "harini",lname = "sara")
"""
Using the key & value programming
"""
def vp_fun(**kwargs):
for key, value in kwargs.items():
print("%s == %s" % (key, value))
# Driver code
vp_fun(first='hello', mid='world', last='python')
"""
declarartion of global variable
"""
x = "Easy"
def myfun():
print("python is " + x)
myfun()
"""
Using global Keyword
"""
def met():
global y
y = "awersome"
met()
print("Python is " + y)
"""
Passing a list as argu
"""
def list_func(food):
for x in food:
print(x)
eat = ["chicken biryani","shawarma","chicken 65"]
list_func(eat)
"""
Return Values
"""
def val_func(x):
return(25 * x)
print(val_func(4))
print(val_func(6))
"""
pass statement just the function to define
with any error
"""
def df_func():
pass
"""
Recursion function
"""
def rec_func(k):
if(k<10):
result = k +rec_func(k+1)
print(k)
else:
result = 0
return result
print("Recursion Example Result")
rec_func(0)