create account

reduce Fonksiyonu # 1 - Python Dersleri (Tutorials) by elektroyazilim

View this thread on: hive.blogpeakd.comecency.com
· @elektroyazilim ·
$12.31
reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)
![yeni.jpg](https://cdn.steemitimages.com/DQmVqEHkajCZyuMfc1Nn7AfRj9QwYTddNmLcySkpi48PD1S/yeni.jpg) 

Merhabalar

Python programlama derslerinin bu bölümünde yine gömülü fonksiyonlardan biri olan _reduce()_ fonksiyonuna başlayacağız.

_reduce()_ fonksiyonu da _map()_ fonksiyonu gibi ilk parametre olarak bir fonksiyon alır. 

Hatta genel yapısı birebir aynıdır, diyebiliriz:

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

_reduce()_ fonksiyonu ilk parametre olarak bir fonksiyon alırken ikinci parametre olarak içerisinde gezinebileceği dizisel bir yapı alır. Bu yapı liste, demet veya herhangi bir veri tipinden olabilir.

_reduce()_ fonksiyonunun çalışma mantığı ise oldukça gariptir. Bir örnek üzerinden anlatayım. Dizisel elemanımızın bir liste olduğunu farz edelim. 

_reduce_ fonksiyonu parametre olarak aldığı fonksiyona listeden ilk iki elemanı fonksiyon parametresi olarak gönderir. Sonrasında fonksiyondan dönen sonuç ile beraber listenin bir sonraki elemanını tekrar aynı fonksiyona parametre olarak gönderir. Bu süreç listede eleman kalmayana kadar devam eder.

Tanımdan çok bir şey anlaşılmayabilir, biz en iyisi uygulamasına geçelim:

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

Örneğimiz

> from functools import reduce

kodu ile başlamaktadır. _reduce()_ fonksiyonu, _functools_ modülünde tanımlıdır. Bu sebeple bu fonksiyonu kullanabilmek için  programın başında böyle bir _import_ işlemi yapmamız gerekir.

Sonrasında _carp()_ fonksiyonunu görüyoruz, iki parametre almaktadır. Aldığı parametreleri çarparak sonuç olarak döndürür.

> reduce(carp,[1,2,3,4,5])

kodu ile fonksiyonu çalıştırıyoruz. 

_reduce()_ fonksiyonuna ilk olarak iki parametre gidecektir : 1 ve 2. Bu iki parametre  _carp()_ fonksiyonuna gönderildikten sonra 1*2 = 2 olarak geri dönecektir.

Sonrasında 2 sonucu elimizde tutularak listenin 3.elemanı olan 3 alınacaktır. Bu iki sayı da _carp()_ fonksiyonuna gönderildikten sonra 2 * 3 = 6 olarak geri döner. 

Tekrardan 6 ile beraber bu sefer 4.eleman olan 4 sayısı alınıp _carp()_ fonksiyonuna gönderilir.  _carp()_ fonksiyonuna gönderilen 6 ve 4 parametreleri 6 * 4= 24 olarak geri döner.

Son olarak 24 sayısı listenin 5.elemanı ile alınır ve tekrardan _carp()_ fonksiyonuna gönderilir ve listede başka eleman kalmadığından nihai değer elde edilir : 24 * 5 = 120

Sonucumuz 120'dir. 






Ş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
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 2 others
👎  
properties (23)
authorelektroyazilim
permlinkreduce-fonksiyonu-1-python-dersleri-tutorials
categorypalnet
json_metadata{"tags":["palnet","zzan","stem","tr","marlians","programming","python","realityhubs"],"image":["https://cdn.steemitimages.com/DQmVqEHkajCZyuMfc1Nn7AfRj9QwYTddNmLcySkpi48PD1S/yeni.jpg","https://cdn.steemitimages.com/DQmUGFGxpYA49hbxBYxVbrVVAmyhEjXiPTBqz8o6gWnY4LY/image.png","https://cdn.steemitimages.com/DQmUoiLLQHBVz7tx9pfGLQc6SautE8rVGApp5w9k35daM1x/image.png","https://cdn.steemitimages.com/DQmYZw2bhUomeivJwQ8CiLaTzXTbJPLd1PsSGdcoEE1DfKP/yesilayrca.png"],"app":"realityhubs/0.1","format":"markdown"}
created2019-08-10 06:46:42
last_update2019-08-10 06:46:42
depth0
children9
last_payout2019-08-17 06:46:42
cashout_time1969-12-31 23:59:59
total_payout_value9.358 HBD
curator_payout_value2.956 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,712
author_reputation73,919,354,200,140
root_title"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,359,957
net_rshares36,856,416,240,791
author_curate_reward""
vote details (67)
@bid4joy ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190812t124251268z
You got a 50.00% upvote from @bid4joy courtesy of @elektroyazilim!
properties (22)
authorbid4joy
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190812t124251268z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-12 12:42:51
last_update2019-08-12 12:42:51
depth1
children0
last_payout2019-08-19 12:42:51
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_length67
author_reputation11,746,524,585,557
root_title"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,437,441
net_rshares0
@brupvoter ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190812t062010351z
You got a 67.01% upvote from @brupvoter courtesy of @elektroyazilim!
properties (22)
authorbrupvoter
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190812t062010351z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-12 06:20:09
last_update2019-08-12 06:20:09
depth1
children0
last_payout2019-08-19 06:20:09
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"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,428,197
net_rshares0
@joeparys ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190812t211401720z
You got a 19.05% 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-reduce-fonksiyonu-1-python-dersleri-tutorials-20190812t211401720z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-12 21:14:00
last_update2019-08-12 21:14:00
depth1
children0
last_payout2019-08-19 21:14:00
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"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,453,987
net_rshares0
@lovejuice ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t005701500z
This post has received a 22.22% upvote from @lovejuice thanks to @elektroyazilim. They love you, so does Aggroed. Please be sure to vote for Witnesses at https://steemit.com/~witnesses.
properties (22)
authorlovejuice
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t005701500z
categorypalnet
json_metadata{"app":"postpromoter/1.7.4"}
created2019-08-13 00:57:00
last_update2019-08-13 00:57:00
depth1
children0
last_payout2019-08-20 00:57:00
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_length185
author_reputation10,538,740,461,622
root_title"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,459,348
net_rshares0
@luckyvotes ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190815t143918281z
You got a 96.53% upvote from @luckyvotes courtesy of @elektroyazilim!
properties (22)
authorluckyvotes
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190815t143918281z
categorypalnet
json_metadata{"app":"postpromoter/2.1.2"}
created2019-08-15 14:39:18
last_update2019-08-15 14:39:18
depth1
children0
last_payout2019-08-22 14:39:18
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"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,560,983
net_rshares0
@minnowvotes ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t123634894z
You got a 96.32% upvote from @minnowvotes courtesy of @elektroyazilim!
properties (22)
authorminnowvotes
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t123634894z
categorypalnet
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-13 12:36:36
last_update2019-08-13 12:36:36
depth1
children0
last_payout2019-08-20 12:36: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"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,476,491
net_rshares0
@redlambo ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t131451053z
You got a 50.00% upvote from @redlambo courtesy of @elektroyazilim! Make sure to use tag #redlambo to be considered for the curation post!
properties (22)
authorredlambo
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t131451053z
categorypalnet
json_metadata{"app":"postpromoter/1.9.2"}
created2019-08-13 13:14:51
last_update2019-08-13 13:14:51
depth1
children0
last_payout2019-08-20 13:14:51
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_length139
author_reputation123,143,757,359
root_title"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,477,662
net_rshares0
@whalecreator ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t121801015z
You got a 50.00% upvote from @whalecreator courtesy of @elektroyazilim! Delegate your Steem Power to earn 100% payouts.
properties (22)
authorwhalecreator
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t121801015z
categorypalnet
json_metadata{"app":"postpromoter/1.9.3"}
created2019-08-13 12:18:00
last_update2019-08-13 12:18:00
depth1
children0
last_payout2019-08-20 12:18:00
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_length120
author_reputation-582,393,550,059
root_title"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,475,912
net_rshares0
@whalepromobot ·
re-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t124543072z
You got a 50.00% upvote from @whalepromobot courtesy of @elektroyazilim!
properties (22)
authorwhalepromobot
permlinkre-elektroyazilim-reduce-fonksiyonu-1-python-dersleri-tutorials-20190813t124543072z
categorypalnet
json_metadata{"app":"postpromoter/2.0.0"}
created2019-08-13 12:45:42
last_update2019-08-13 12:45:42
depth1
children0
last_payout2019-08-20 12:45:42
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_length73
author_reputation-231,775,391,844
root_title"reduce Fonksiyonu # 1 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,476,770
net_rshares0