Page 10 - Bilgisayar Bilimi-Kur 1- 2017-2018
P. 10
3.5. İfadeleri Biçimlendirme ........................................................................................................................................................................................................................................................................................................... 128
3.6. Yorumlar ........................................................................................................................................................................................................................................................................................................................................................... 129
3.7. Hatalar ................................................................................................................................................................................................................................................................................................................................................................... 129
3.7.1. Çalışma Zamanı Hataları .................................................................................................................................................................................................................................................................................. 130
3.7.2. Mantık Hataları ................................................................................................................................................................................................................................................................................................................ 130
3.8. Aritmetik Örnekler ......................................................................................................................................................................................................................................................................................................................... 130
3.9. Aritmetik İfadeler ............................................................................................................................................................................................................................................................................................................................... 131
4. KOŞULLU DURUMLAR
4.1. Boolean İfadesi ........................................................................................................................................................................................................................................................................................................................................ 133
4.2. Python’da İlişkisel Operatörler ................................................................................................................................................................................................................................................................................... 133
4.3. “if” İfadesi ....................................................................................................................................................................................................................................................................................................................................................... 133
4.4. “if/else” İfadesi ......................................................................................................................................................................................................................................................................................................................................... 134
4.5. Birleşik Boolean İfadesi ............................................................................................................................................................................................................................................................................................................ 135
4.6. Pass İfadesi ..................................................................................................................................................................................................................................................................................................................................................... 136
4.7. Kayan Noktalı Eşitlik .................................................................................................................................................................................................................................................................................................................. 136
4.8. İç İçe Koşul İfadeleri ..................................................................................................................................................................................................................................................................................................................... 136
4.9. Çok Yönlü Karar İfadeleri .................................................................................................................................................................................................................................................................................................... 137
4.10. Çok Yönlü ve Zincirleme Durum İfadeleri ......................................................................................................................................................................................................................................... 138
4.11. Koşullu İfadeler .................................................................................................................................................................................................................................................................................................................................. 139
4.11.1. Koşullu İfadelerde Hatalar ........................................................................................................................................................................................................................................................................... 139
4.12. Mantık Karmaşası ......................................................................................................................................................................................................................................................................................................................... 140
5. DÖNGÜLER
5.1. Döngü Yapıları ........................................................................................................................................................................................................................................................................................................................................ 143
5.2. For Döngüsü .............................................................................................................................................................................................................................................................................................................................................. 143
5.2.1. For Döngüsü İçin Söz Dizimi ................................................................................................................................................................................................................................................................... 144
5.2.2. For Döngüsü İçin Farklı Örnekler .................................................................................................................................................................................................................................................... 144
5.3. İç İçe Döngüler ....................................................................................................................................................................................................................................................................................................................................... 147
5.4. İç İçe 3’lü Döngü ................................................................................................................................................................................................................................................................................................................................ 150
5.5. While Döngüsü ..................................................................................................................................................................................................................................................................................................................................... 150
5.5.1. While Döngüsü İçin Söz Dizimi .......................................................................................................................................................................................................................................................... 150
5.5.2. While Döngüsü İçin Akış Şeması ....................................................................................................................................................................................................................................................... 151
5.6. Belirli ve Belirsiz Döngüler ............................................................................................................................................................................................................................................................................................... 154
5.7. Döngü’den Çıkma Komutları ....................................................................................................................................................................................................................................................................................... 155
5.7.1. Break İfadesi ............................................................................................................................................................................................................................................................................................................................. 155
5.7.2. Continue İfadesi ................................................................................................................................................................................................................................................................................................................ 156
5.7.3. While/else ve for/else .................................................................................................................................................................................................................................................................................................. 157
5.8. Döngü Örnekleri ................................................................................................................................................................................................................................................................................................................................ 158
6. FONKSİYONLAR 1
6.1. Neden Fonksiyonlar? .................................................................................................................................................................................................................................................................................................................... 162
6.2. Fonksiyon Nedir? ............................................................................................................................................................................................................................................................................................................................... 162
6.3. Fonksiyonlara Giriş ........................................................................................................................................................................................................................................................................................................................ 162
6.3.1. sqrt() Fonksiyonu ............................................................................................................................................................................................................................................................................................................ 163
6.3.1.1. sqrt() Fonksiyonunun Farklı Kullanımları ...................................................................................................................................................................................................... 163
6.3.2. Fonksiyonların Bölümleri ................................................................................................................................................................................................................................................................................ 164
6.3.3. Parametresiz Fonksiyonlar .............................................................................................................................................................................................................................................................................. 165
X