-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUDF.py
More file actions
153 lines (118 loc) · 2.16 KB
/
Copy pathUDF.py
File metadata and controls
153 lines (118 loc) · 2.16 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Creating sample function
# def test(x,y,z):
# res1 = x + y + z
# return res1
#
# op = test(10,10,80)
# print(op)
#
# op = test(3,2,1)
# print(op)
#
# op = test(7,2,1)
# print(op)
### Sample use of function
# def mobval(num):
# res1 = len(num)
# res2 = num.isdigit()
# if(res1 == 10 and res2 == True):
# return "Valid Number"
# else:
# return "invalid number"
# op = mobval("176171")
# print(op)
#
# op = mobval("616116")
# print(op)
#
# op = mobval("9986019197")
# print(op)
#
# op = mobval('74116dsdgwkdg')
# print(op)
# =======================================================
# local and global variable concept
# any variable created inside the function is Local Variable
# any variable created outside the function is global Variable
# place = "bangalore"
#
# def test(x,y,z):
# global name
# name = "santhosh"
# print("inside = ", place)
# res = x + y + z
# return res
#
# op = test(30,10,5)
# print(op)
#
# print("outside = ", name)
# Explaining multiple return statements
# def test(x,y,z):
# res1 = x + y + z
# res2 = x - y - z
# res3 = x * y * z
# return res1,res2,res3
#
# op = test(20,10,5)
# print(op)
# types of UDF
# 1. required and positional arg
# def test(x,y,z):
# res = x + y + z
# return res
#
# op = test(20,10,5)
# print(op)
# 2. required and non positional keyword arg
# def test(x,y,z):
# res = x + y + z
# return res
#
# op = test(y = 50,z = 10, x = 40)
# print(op)
# 3. default arg func
# def test(x=300,y=1000,z=500):
# res = x + y + z
# return res
#
# op = test()
# print(op)
# # # 4. variable length arg func
# Var leng arg shld always be at last
# def test(*z):
# # print(x)
# # print(y)
# print(z)
#
# test(10,20,30,40,50,60,70)
#
# def test(**kwargs):
# print(kwargs)
#
# test(name='sandy', age=20,place='blr')
#
#
#
#
#
#
#
#
# res1 = 99
#
# def test(x,y,z):
# global res1,res2,res3
# res1 = x + y + z
# res2 = x - y - z
# res3 = x * y * z
# return res1,res2,res3
#
# op = test(20,10,5)
# print(op)
#
#
# print("res1 = " , res1)
palindrome = lambda s: "s" == "[-1]"
res = palindrome("pranatas")
print(res)