create account

filter() fonksiyonu # 2 - Python Dersleri (Tutorials) by elektroyazilim

View this thread on: hive.blogpeakd.comecency.com
· @elektroyazilim ·
$13.56
filter() fonksiyonu # 2 - Python Dersleri (Tutorials)
![yeni.jpg](https://cdn.steemitimages.com/DQmVqEHkajCZyuMfc1Nn7AfRj9QwYTddNmLcySkpi48PD1S/yeni.jpg) 

Merhabalar

Python programlama derslerinin bu bölümünde gömülü fonksiyonlardan biri olan _filter()_ fonksiyonundan devam edeceğiz.

_filter()_ fonksiyonu, parametre olarak aldığı fonksiyonun işlevine göre liste elemanlarını filtreler.

## Asal Sayı Bulma

_filter()_ fonksiyonunu kullanarak verilen bir listedeki asal sayıları bulalım.

_filter()_ kullanımına geçmeden önce ilk olarak _filter()_ fonksiyonuna parametre olarak gidecek olan _asal sayı bulan_ fonksiyonu tanımlayalım :

![](https://cdn.steemitimages.com/DQmZ3JW7FQurDQfweAPqte5MTW4TJpS8EZnAkNwDvnycnTw/image.png)

_asalMi()_ fonksiyonu aldığı sayının asal olup olmadığı bilgisini True veya False olarak döndüren bir fonksiyondur. 

Fonksiyonun içinde 1 adet _if elif_ yapısı içerisinde 3 durum sorgulanmıştır: 
* Gelen sayının 1 olma durumu ki bu Matematikte de özel bir durumdur. 1 sayısı kendinden ver 1 den başka sayıya bölünmemesine rağmen asal bir sayı değildir. Bu sebeple _False_ döndürülmüştür.

* 2.durum ise gelen sayının 2 ye eşit olmama durumudur. 2 sayısı, Matematikte en küçük asal sayı kabul edilir. Bu sebeple _True_ döndürmüştür.

* Son durum ise gelen sayının 1 ve 2 dışında olması durumudur. Bunda da _while()_ döngüsü içerisinde tek tek gelen sayının bölenleri sorgulanmıştır. Bir böleni çıksa dahi _while()_ döngüsü içerisindeki _if()_ yapısına girerek _False_ değeri döndürecektir. Girmese de _True_ döndürecektir.

Uygulamamızın test sonuçları aşağıdaki gibidir :

![](https://cdn.steemitimages.com/DQmXGRG7xnRMLVrZaq4TRkdZdd7FbMBPBvYJDbRvGggfW5M/image.png)

Şimdi bu fonksiyonu _filter()_ fonksiyonu içerisinde kullanalım :

![](https://cdn.steemitimages.com/DQma9NG5imEUD7EKCMQaSA2pFGrzdP6d93pFabyr7fuQBUS/image.png)

_filter()_ fonksiyonunun kullanımı oldukça basit. İlk parametreye fonksiyonu, ikinci parametreye liste veya demet gibi dizisel bir yapıyı veriyoruz.

Sonrası ise sadece çalıştırmaya kalıyor. Sonuç görüldüğü gibi 
> [2, 3, 17, 167]

dir. Programcıya çok pratiklik kazandırdığı anlaşılıyor sanırım.

_filter()_ fonksiyonuna manuel liste verebileceğimiz gibi _range()_ fonksiyonu ile sıralı bir sayı dizisi de verebiliriz. Uygulamasını görelim :

![](https://cdn.steemitimages.com/DQmX4BhD3cJLpj1EBqHYFHT75s25NUB7TXbzCuuu8S9B2An/image.png)

_renge()_ fonksiyonu ile 1 den 37 ye kadar olan sayılar arasında _asal sayı_ araması yapıldı ve sonuç çıktıdaki gibidir. 
 > Son eleman dahil değildir.

Şimdilik bu kadar.

Umarım faydalı bir çalışma olmuştur.

Teşekkürler.

![yesilayrca.png](https://cdn.steemitimages.com/DQmYZw2bhUomeivJwQ8CiLaTzXTbJPLd1PsSGdcoEE1DfKP/yesilayrca.png)

Kaynak belirtilmeyen görseller bana aittir. The pictures without source in the post is belong to me

<hr><center><sub>Posted via <a href="https://www.marlians.com/">Marlians.com</a></sub></center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorelektroyazilim
permlinkfilter-fonksiyonu-2-python-dersleri-tutorials
categorypalnet
json_metadata{"tags":["palnet","zzan","stem","tr","programming","python","marlians"],"image":["https://cdn.steemitimages.com/DQmVqEHkajCZyuMfc1Nn7AfRj9QwYTddNmLcySkpi48PD1S/yeni.jpg","https://cdn.steemitimages.com/DQmZ3JW7FQurDQfweAPqte5MTW4TJpS8EZnAkNwDvnycnTw/image.png","https://cdn.steemitimages.com/DQmXGRG7xnRMLVrZaq4TRkdZdd7FbMBPBvYJDbRvGggfW5M/image.png","https://cdn.steemitimages.com/DQma9NG5imEUD7EKCMQaSA2pFGrzdP6d93pFabyr7fuQBUS/image.png","https://cdn.steemitimages.com/DQmX4BhD3cJLpj1EBqHYFHT75s25NUB7TXbzCuuu8S9B2An/image.png","https://cdn.steemitimages.com/DQmYZw2bhUomeivJwQ8CiLaTzXTbJPLd1PsSGdcoEE1DfKP/yesilayrca.png"],"app":"marlians/0.1","format":"markdown"}
created2019-08-11 18:11:00
last_update2019-08-11 18:11:00
depth0
children6
last_payout2019-08-18 18:11:00
cashout_time1969-12-31 23:59:59
total_payout_value10.309 HBD
curator_payout_value3.250 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,881
author_reputation73,919,354,200,140
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,411,713
net_rshares40,175,787,424,077
author_curate_reward""
vote details (60)
@brupvoter ·
re-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190814t112626650z
You got a 67.05% upvote from @brupvoter courtesy of @elektroyazilim!
properties (22)
authorbrupvoter
permlinkre-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190814t112626650z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-14 11:26:27
last_update2019-08-14 11:26:27
depth1
children0
last_payout2019-08-21 11:26:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length69
author_reputation13,657,314,846,422
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,515,014
net_rshares0
@joeparys ·
re-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190815t014756070z
You got a 17.85% upvote from @joeparys! Thank you for your support of our services. To continue your support, please follow and delegate Steem power to @joeparys for daily steem and steem dollar payouts!
properties (22)
authorjoeparys
permlinkre-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190815t014756070z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-15 01:47:54
last_update2019-08-15 01:47:54
depth1
children0
last_payout2019-08-22 01:47:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length204
author_reputation308,134,181,812,267
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,540,928
net_rshares0
@luckyvotes ·
re-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190816t193814666z
You got a 96.97% upvote from @luckyvotes courtesy of @elektroyazilim!
properties (22)
authorluckyvotes
permlinkre-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190816t193814666z
categorypalnet
json_metadata{"app":"postpromoter/2.1.2"}
created2019-08-16 19:38:15
last_update2019-08-16 19:38:15
depth1
children0
last_payout2019-08-23 19:38:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length70
author_reputation29,364,484,293
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,608,524
net_rshares0
@minnowvotes ·
re-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190814t094334871z
You got a 94.09% upvote from @minnowvotes courtesy of @elektroyazilim!
properties (22)
authorminnowvotes
permlinkre-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190814t094334871z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-14 09:43:36
last_update2019-08-14 09:43:36
depth1
children0
last_payout2019-08-21 09:43:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length71
author_reputation-125,291,280,752
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,511,627
net_rshares0
@steemitboard ·
Congratulations @elektroyazilim! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://steemitimages.com/60x60/http://steemitboard.com/img/notifications/postallweek.png"></td><td>You published a post every day of the week</td></tr>
</table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@elektroyazilim) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=elektroyazilim)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>


To support your work, I also upvoted your post!


> You can upvote this notification to help all Steem users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-elektroyazilim-20190812t033147000z
categorypalnet
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2019-08-12 03:31:48
last_update2019-08-12 03:31:48
depth1
children0
last_payout2019-08-19 03:31:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length859
author_reputation38,975,615,169,260
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,424,487
net_rshares0
@steemyoda ·
re-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190815t200044422z
The force is with you! You got a 25.00% upvote from @steemyoda courtesy of @elektroyazilim!

http://ultraimg.com/images/2018/02/27/n8qb.gif
properties (22)
authorsteemyoda
permlinkre-elektroyazilim-filter-fonksiyonu-2-python-dersleri-tutorials-20190815t200044422z
categorypalnet
json_metadata{"app":"postpromoter/2.0.0"}
created2019-08-15 20:00:48
last_update2019-08-15 20:00:48
depth1
children0
last_payout2019-08-22 20:00:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length140
author_reputation-1,181,563,121,002
root_title"filter() fonksiyonu # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,571,311
net_rshares0