Page 11 - Bilgisayar Bilimi-Kur 1- 2017-2018
P. 11
6.3.4. Değer Döndürmeyen Fonksiyonlar ................................................................................................................................................................................................................................................. 165
6.4. Fonksiyon ve Modüller ............................................................................................................................................................................................................................................................................................................. 166
6.5. Yerleşik İşlevler ........................................................................................................................................................................................................................................................................................................................................ 167
6.6. Standart Matematik Fonksiyonları ...................................................................................................................................................................................................................................................................... 168
6.7. time Fonksiyonları ............................................................................................................................................................................................................................................................................................................................ 170
6.8. Rastgele Sayılar ...................................................................................................................................................................................................................................................................................................................................... 172
7. FONKSİYON YAZMA
7.1. Fonksiyon Kavramı .......................................................................................................................................................................................................................................................................................................................... 175
7.1.1. Fonksiyon Tanımlama ............................................................................................................................................................................................................................................................................................. 175
7.1.2. Fonksiyon Yazma ............................................................................................................................................................................................................................................................................................................. 175
7.1.3. Fonksiyon Çağırma ...................................................................................................................................................................................................................................................................................................... 175
7.2. Fonksiyon Kullanımı Örnekleri ................................................................................................................................................................................................................................................................................ 176
7.3. Değer Gönderme ile İlgili Olası Sorunlar ................................................................................................................................................................................................................................................. 178
7.4. Çoklu Değer Gönderme Örnekleri ....................................................................................................................................................................................................................................................................... 178
7.4.1. Grafik Ortamda Beşgen Çizimi .............................................................................................................................................................................................................................................................. 178
7.4.2. En Büyük Ortak Çarpan Fonksiyonu .......................................................................................................................................................................................................................................... 179
7.5. Yerel Değişken .......................................................................................................................................................................................................................................................................................................................................... 180
7.6. Fonksiyon Yazarken Fonksiyon Sıralamasını Belirleme .................................................................................................................................................................................................... 181
7.6.1. Girilen İki Değerin En Büyük Ortak Böleni .................................................................................................................................................................................................................... 181
7.7. Parametre Gönderme ..................................................................................................................................................................................................................................................................................................................... 182
7.8. Fonksiyon Yazarken Tanımlayıcı Bilgileri Ekleme .................................................................................................................................................................................................................... 183
7.9. Fonksiyon Örnekleri ...................................................................................................................................................................................................................................................................................................................... 184
7.9.1 Asal Sayıların Bulunması ...................................................................................................................................................................................................................................................................................... 184
7.9.3 Kısıtlı Veri Girişi ................................................................................................................................................................................................................................................................................................................. 186
7.9.4 Ağaç Çizimi ................................................................................................................................................................................................................................................................................................................................. 187
8. FONKSİYONLAR 2
8.1. Global Değişkenler .......................................................................................................................................................................................................................................................................................................................... 189
8.2. Örnekler ............................................................................................................................................................................................................................................................................................................................................................ 189
8.2.1. Hesap Makinesi Örneği ...................................................................................................................................................................................................................................................................................... 189
8.2.2. Varsayılan (Default) Parametreler ..................................................................................................................................................................................................................................................... 191
8.2.3. Varsayılan ve Diğer Parametreler ........................................................................................................................................................................................................................................................ 191
8.2.4. Gelişmiş Poligon Çizimi .................................................................................................................................................................................................................................................................................. 192
8.2.5. Öz Yineleme ............................................................................................................................................................................................................................................................................................................................ 193
8.2.6. Öz Yineleme Olmadan Faktöriyel Hesaplama ............................................................................................................................................................................................................. 194
8.2.7. Fibonacci Sayıları ............................................................................................................................................................................................................................................................................................................ 195
8.3. Fonksiyonları Tekrar Kullanılabilir Yapma ........................................................................................................................................................................................................................................... 195
9. NESNELER
9.1. Nesne Kavramı ........................................................................................................................................................................................................................................................................................................................................ 198
9.2. Nesneleri Kullanmak ................................................................................................................................................................................................................................................................................................................... 198
9.3. Dizi Nesneleri ........................................................................................................................................................................................................................................................................................................................................... 198
9.3.1 str Nesnesi İçin Yöntemler ................................................................................................................................................................................................................................................................................ 200
9.3.2 getitem Kullanımı ........................................................................................................................................................................................................................................................................................................... 201
9.4. Dosya Nesneleri .................................................................................................................................................................................................................................................................................................................................... 202
9.4.1. Dosya Okuma ve Yazma İşlemleri ................................................................................................................................................................................................................................................... 204
9.4.2. Dosya Okuma ve Yazma İşlemlerinde with/as kullanımı ......................................................................................................................................................................... 204
9.4.3. TextIOWrapper Yöntemleri .......................................................................................................................................................................................................................................................................... 206
XI