Created
March 30, 2011 11:17
-
-
Save symtkn/894222 to your computer and use it in GitHub Desktop.
sayının en büyük basamağını bulup onu sayı olarak döndüren 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 en_buyuk_basamak(sayi): | |
a = repr(sayi) #Sayıyı karakter dizisine çeviriyoruz. | |
b = 0 #Basamak değeri en küçük sıfır olabileceğinden,değişkene sıfır değerini atıyoruz. | |
for i in a : | |
i = int(i) #a daki öğeyi integer'a çeviriyoruz. | |
if i >= b : b = i #eğer i deki değer b dekinden büyükse,değeri b ye atıyoruz | |
else : pass #Küçük değilse de es geçiyoruz. | |
return b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment