Skip to content

Instantly share code, notes, and snippets.

@symtkn
Created March 30, 2011 11:20
Show Gist options
  • Save symtkn/894225 to your computer and use it in GitHub Desktop.
Save symtkn/894225 to your computer and use it in GitHub Desktop.
verilen bir sayının basamkaları toplamını hesaplayan program
# -*- 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