Değişkenler # 2 - Python Dersleri (Tutorials) by elektroyazilim

View this thread on steempeak.com
· @elektroyazilim · (edited)
$8.98
Değişkenler # 2 - Python Dersleri (Tutorials)
![kapak.jpg](https://cdn.steemitimages.com/DQmThdi5LSucjta2n6jp6kkyrJ1AgEhC3uAVRVVZaMzowQW/kapak.jpg)

Merhabalar

Python programlama derslerinin bu bölümünde değişkenler konusundan devam edeceğiz.

> Bu ders bir önceki dersteki bilgiler üzerine bina edileceğinden öncelikle o ders bakmanız tavsiye edilir.

Bir önceki dersimizde global ve yerel değişkenlerden bahsetmiştik. Bu dersimizde bahsetmediğimiz noktalara değineceğiz.

Python'da yerel değişkenler, fonksiyon blokları içerisinde tanımlanan değişkenlerdir ve fonksiyon bloğu içerisinden erişilebilirler. Fonksiyon çalışması bittiğinde bellekten silinirler.

Yani biz yerel bir değişkene programın genelinden erişemeyiz. Ancak global değişkenler, genel değişkenler olduğundan programın her yerinden erişilebilirler.

Şimdi aşağıdaki uygulamaya bakalım :

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

Örneğimizde sayi adında bir değişkenimiz ve functionTest() adında bir fonksiyonumuz var.  sayi değişkenimiz global olarak tanımlanmıştır.

> Buna benzer bir uygulamayı bir önceki dersimizde yapmıştık.

functionTest() fonksiyonundaki print() fonksiyonu global olarak tanımlanan sayi değişkenini ekrana yazdırmaktadır. 

sayi değişkenimizin kapsama alanını düşündüğümüzde fonksiyondan da erişilebilir olduğunu söyleyebiliriz.

sayi değişkenimiz tanımladıktan sonra functionTest() fonksiyonu çağrılmıştır. Peki tam tersi olsaydı yani ilk olarak fonksiyon çağrılıp sonra değişken tanımlansaydı :

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

> name 'st' is not defined

şeklinde bir hata aldık. 

Programlar çalıştırılırken kodlar yukarıdan aşağıya doğru çalıştırıldığından functionTestt() fonksiyonu çalıştırıldığında daha st değişkeni var olmamıştır.

Bu hatanın sebebi st değişkenin var olmamasıdır. Böyle bir hatayla karşılaşmamak için global değişkenlerin kullanım yerine dikkat edilmelidir.

Ş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
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id77,979,044
authorelektroyazilim
permlink2t7h2y-degiskenler-2-python-dersleri-tutorials
categorypalnet
json_metadata{"app":"steemit\/0.1","format":"markdown","tags":["palnet","tutorials","programming","zzan","python"],"image":["https:\/\/cdn.steemitimages.com\/DQmThdi5LSucjta2n6jp6kkyrJ1AgEhC3uAVRVVZaMzowQW\/kapak.jpg","https:\/\/cdn.steemitimages.com\/DQmWTv1F5NYVVCLTfiBpUnznyYqGUpp7wd8usXNpLGPMNWh\/image.png","https:\/\/cdn.steemitimages.com\/DQmSSGxkKZy7s9bymgRAacP9AM75FbbtfWqWuyscZR6w8BR\/image.png","https:\/\/cdn.steemitimages.com\/DQmYZw2bhUomeivJwQ8CiLaTzXTbJPLd1PsSGdcoEE1DfKP\/yesilayrca.png"]}
created2019-07-15 19:09:33
last_update2019-07-15 19:14:54
depth0
children3
net_rshares24,772,070,825,976
last_payout2019-07-22 19:09:33
cashout_time1969-12-31 23:59:59
total_payout_value6.799 SBD
curator_payout_value2.180 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,233
author_reputation73,941,607,658,612
root_title"Değişkenler # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (62)
@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/60x70/http://steemitboard.com/@elektroyazilim/votes.png?201907151206"></td><td>You distributed more than 800 upvotes. Your next target is to reach 900 upvotes.</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)
post_id77,980,470
authorsteemitboard
permlinksteemitboard-notify-elektroyazilim-20190715t200640000z
categorypalnet
json_metadata{"image":["https:\/\/steemitboard.com\/img\/notify.png"]}
created2019-07-15 20:06:39
last_update2019-07-15 20:06:39
depth1
children0
net_rshares0
last_payout2019-07-22 20:06:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length902
author_reputation38,705,954,145,809
root_title"Değişkenler # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steemyoda ·
re-elektroyazilim-2t7h2y-degiskenler-2-python-dersleri-tutorials-20190719t144619096z
The force is with you! You got a 10.43% upvote from @steemyoda courtesy of @elektroyazilim!

http://ultraimg.com/images/2018/02/27/n8qb.gif
properties (22)
post_id78,119,022
authorsteemyoda
permlinkre-elektroyazilim-2t7h2y-degiskenler-2-python-dersleri-tutorials-20190719t144619096z
categorypalnet
json_metadata{"app":"postpromoter\/2.0.0"}
created2019-07-19 14:46:24
last_update2019-07-19 14:46:24
depth1
children0
net_rshares0
last_payout2019-07-26 14:46:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length140
author_reputation-772,285,316,720
root_title"Değişkenler # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@minnowvotes ·
re-elektroyazilim-2t7h2y-degiskenler-2-python-dersleri-tutorials-20190720t005902950z
You got a 90.26% upvote from @minnowvotes courtesy of @elektroyazilim!
properties (22)
post_id78,133,677
authorminnowvotes
permlinkre-elektroyazilim-2t7h2y-degiskenler-2-python-dersleri-tutorials-20190720t005902950z
categorypalnet
json_metadata{"app":"postpromoter\/2.1.1"}
created2019-07-20 00:59:03
last_update2019-07-20 00:59:03
depth1
children0
net_rshares0
last_payout2019-07-27 00:59:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length71
author_reputation-300,453,853,020
root_title"Değişkenler # 2 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000