1000 * 20 / 100 + 1000 maaslar[0] * 20 / 100 + maaslar[0] maaslar[1] * 20 / 100 + maaslar[1] maaslar[2] * 20 / 100 + maaslar[2] #dongu yazilacak #fonksiyon yazmak def yeni_maas(x): print(x) yeni_maas(4) def yeni_maas(x): print(x * 20 / 100 + x) yeni_maas(1000) yeni_maas(2000) yeni_maas(3000) for i in maaslar: yeni_maas(i) #mini uygulama #if, for ve fonksiyonlari birlikte kullanmak
#baska dosyadan #Fonksiyon cagirdik import HesapModulu HesapModulu.yeni_maas(1000) import HesapModulu as hm hm.yeni_maas(1000) from HesapModulu import yeni_maas yeni_maas(444) import HesapModulu as hm hm.maaslar ##Exceptionssss #except yapisi hatayi es gecer a = 10 b = 0 a/b #(ZeroDevisionError)
# -*- coding: utf-8 -*- """ Created on Sun Apr 19 14:16:03 2020 @author: Gökhan """ # ============================================================================= # modül oluşturmak # ============================================================================= # belli bir amacı yerine getirmek için toplu işlemleri içerir import HesapModulu HesapModulu.yeni_maas(800) # kısa isim vererek kullanma import HesapModulu as hm hm.yeni_maas(1000) # sadece o modülü kullanmak istiyorsak from HesapModulu import yeni_maas yeni_maas(4000) # modülün içindeki değerlere ulaşma import HesapModulu as hm hm.maaslar
#reduce from functools import reduce liste = [1,2,3,4] reduce(lambda a,b: a + b, liste) #Modul Olusturmak #HesapModulu.py def yeni_maas(x): print(x*20/100 + x) maaslar = [1000,2000,3000,4000] #test import HesapModulu HesapModulu.yeni_maas(1000) import HesapModulu as hm hm.yeni_maas(2000) from HesapModulu import yeni_maas yeni_maas(3000) import HesapModulu as hm hm.maaslar