Created
March 30, 2011 11:20
-
-
Save symtkn/894225 to your computer and use it in GitHub Desktop.
verilen bir sayının basamkaları toplamını hesaplayan program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#!/usr/bin/env python | |
def basamak_degeri_topla(sayi): | |
deger = 0 | |
while sayi : | |
basamak = sayi % 10 #Sayının modülünü alıp basamak degiskenine atadık. | |
sayi = sayi / 10 | |
deger += basamak #Basamak degerini,deger adlı değişkene atadık. | |
print "toplam = %s"% (deger) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment