Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wpforms-lite domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the businext domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the businext domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114
Python While Tamsayıları Toplama Örneği - RAGIP ÜNAL

Blog

Python While Tamsayıları Toplama Örneği

Python’da while döngüsünü bir önceki makalede inceledik. Aşağıdaki örnekle pekiştirelim.

Girilen pozitif sayıların miktarı ve toplamın bulan ve negatif bir sayışı ile programın akışı durdurulan bir program yazacağız.

print("Bir Tamsayı giriniz\n")
print("İşlemi durdurmak için ise \n")
print("Negatif bir tamsayı girin. \n")
say=input("Tamsayı... ")
say=int(say)
sayac=0
toplam=0
while say > 0:
    sayac+=1
    toplam+=say
    say=input("Tamsayı... ")
    say=int(say)
print("\nGirdiğiniz pozitif tam sayıların miktarı=", sayac)
print("\nGirdiğiniz pozitif sayıların toplamı=", toplam)

Programımızın çıktısı:

Bir Tamsayı giriniz

İşlemi durdurmak için ise

Negatif bir tamsayı girin.

Tamsayı... 12
Tamsayı... 65
Tamsayı... 45
Tamsayı... 32
Tamsayı... 78
Tamsayı... -9

Girdiğiniz pozitif tam sayıların miktarı= 5

Girdiğiniz pozitif sayıların toplamı= 232

006_while.py

Leave A Comment

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir