Skip to content

Instantly share code, notes, and snippets.

@gceylan
Created March 27, 2012 15:06
Show Gist options
  • Save gceylan/2216696 to your computer and use it in GitHub Desktop.
Save gceylan/2216696 to your computer and use it in GitHub Desktop.
sinav sorularinin cozumleri
#-*- coding: utf-8 -*-
def en_buyuk_ardil_toplam(dizi):
dizi2 = [0] * len(dizi)
en_buyuk = 0
for ind, i in enumerate(dizi):
if ind == 0:
dizi2[ind] = dizi[ind]
else:
dizi2[ind] = dizi[ind] + dizi2[ind - 1]
if dizi2[i] >= en_buyuk:
en_buyuk = dizi2[i]
print "Girdi >", dizi
print "Ardil toplam >", dizi2
return en_buyuk
#print en_buyuk_ardil_toplam([-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1])
def str_fark(str1, str2):
for i in str1:
if i not in str2:
return i
#print str_fark("abcde", "dafbck")
def simetrik_fark(str1, str2):
result = ''
for i in str1:
if i not in str2:
result += i
for j in str2:
if j not in str1:
result += j
return result
#print simetrik_fark("abcde", "dafbck")
#print simetrik_fark("dafbck", "abcde")
def str3topla(str):
toplam = 0
for i in str:
if i in "1234567890":
i = int(i)
if i % 3 == 0:
toplam += i
return toplam
#print str3topla("a23s56e9x")
def bstr(samanlik, igne):
n = 0
for i in range(0, len(samanlik)):
if samanlik[i] == igne[0]:
for j in range(1, len(igne)):
if samanlik[i + j] == igne[j]:
n += 1
if n == 3:
return i
return -1
#print bstr("110110101011", "1010")
def hecesay(cumle):
sesliler = "aeiouAEIOU"
bosluk, hece = 0, 0
for i in cumle:
if i in sesliler:
hece += 1
elif i == ' ':
bosluk += 1
print "Kelime sayisi:", bosluk + 1
print "Hece sayisi:", hece
#hecesay("alanya")
#hecesay("Bu bir cumle")
@gceylan
Copy link
Author

gceylan commented Mar 28, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment