-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUDF.py
More file actions
65 lines (52 loc) · 1.07 KB
/
Copy pathUDF.py
File metadata and controls
65 lines (52 loc) · 1.07 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
##UDF- User Defined Function
def oddeven(a):
if a%2==0:
print(a, "is Even")
else:
print(a, " is Odd")
##oddeven(5)
def maxof2(a,b):
if a>b:
print(a, "is Max")
else:
print(b, "is Max")
##maxof2(14,17)
def maxof3(a,b,c):
if a>b:
if a>c:
print(a, "is Max")
else:
print(c, "is Max")
## else:
## if b>c:
## print(b, "is Max")
## else:
## print(c, "is Max")
elif b>c:
print(b, "is Max")
else:
print(c, "is Max")
##maxof3(5,6,7)
##maxof3(6,5,7)
##maxof3(15,17,16)
def fibonacci(n):
a,b=0,1
print(a, end=" ")
while b<n:
print(b, end=" ")
## print(b, end=",")
a,b=b,a+b
print()
##fibonacci(56)
def prime(n):
if n%2!=0:
for i in range(3, int(n/2)+1, 2):
if n%i==0:
print(n, "is not Prime.")
break
else:
print(n, "is Prime.")
else:
prime(n, "is not Prime.")
##prime(37)
##prime(57)