-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
81 lines (68 loc) · 1.08 KB
/
test.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
80
81
x="Hello word!"
print(x)
def fact(n):
if n==0 or n==1:
return 1
else:
return n*fact(n-1)
print(fact(10))
def isPrime(n):
i=2
while i<n and n%i!=0:
i=i+1
return i==n
def PrimeNum(l):
i=0
l2=[]
while i<len(l):
if(isPrime(l[i])):
l2.append(l[i])
i=i+1
return l2
def somme(l):
i=0
res=0
while i<len(l):
res+=l[i]
i=i+1
return res
def min(l):
i=0
valMin=l[i]
while i<len(l):
if(valMin>l[i]):
valMin=l[i];
i=i+1
return valMin
def max(l):
i=0
valMax=l[i]
while i<len(l):
if(valMax<l[i]):
valMax=l[i];
i=i+1
return valMax
def reverse(l):
n=len(l)
i=n-1
while i>=0:
tmp=l[i]
l.remove(tmp)
l.append(tmp)
i=i-1
return l
l=[11,21,31,41,51]
l.append(9)#concat/add
l.remove(9)
#l=range(1,10)
res=PrimeNum(l)
print(res)
for i in res:
print(i)
print(somme(l))
print(res)
print(min(l))
print(max(l))
l=['A','L','E','X']
print(l)
print(reverse(l))