- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembd_filter.py
More file actions
Latest commit
52 lines (36 loc) · 909 Bytes
/
Copy pathembd_filter.py
File metadata and controls
52 lines (36 loc) · 909 Bytes
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
"""
filter(fonksiyon, iterasyon yapabilen bir veritipi(liste cvb))
return True, False
"""
""" False ise geri listeye ekleme yapmaz"""
# Çift mi Tek mi Kontrolu
liste= [1, 2, 3, 4, 5, 6]
new_list=filter(lambdax: x%2==0, liste)
print(list(new_list))
ages= [5, 12, 17, 18, 24, 32]
defmyFunc(x):
ifx<18:
returnFalse
else:
returnTrue
adults=filter(myFunc, ages)
forxinadults:
print(x)
"""-----------------------------------------------------"""
defasal_mi(x):
i=2
if (x==1):
# Asal değil
returnFalse
elif(x==2):
# Asal sayı
returnTrue
else:
while(i<x):
if (x%i==0):
# Asal Değil
returnFalse
i+=1
returnTrue
# 1 den 100' e kadar olan asal sayılar.
print("Hakan : ", list(filter(asal_mi, range(1, 100))))