# -*- coding: utf-8 -*- """ paradeigmata me sinartiseis @authors: geokoutsiouri katkaranikola stkarlos """ def ask1(word, char): c = 0 for i in range(0,len(word)): if word[i] == char: c = c + 1 return c print ask1('anaconda' , 'a') print '---------------------new def----------------------' def ask2(l1,l2): l = [] if len(l1) == len(l2): for i in range(0,len(l1)): l.append(l1[i] + l2[i]) return l else: print 'different length of lists' return l l = ask2([1,2,3], [4,4,4]) print l z = ask2([1,1], [2]) print z print '---------------------new def----------------------' def ask3(a,b): if (a % b) == 0: #return True x = True else: #return False x = False return x x = ask3(6,2) print x y = ask3(7,2) print y print '---------------------new def----------------------' def ask4(word,plithos): if plithos > len(word): return 'lathos' else: x = len(word) - plithos return word[0:plithos] + word[x:] print ask4('mathimatiko', 2) print ask4('anna', 8) print '---------------------new def----------------------' def ask5(w1,w2): counter = 0 for i in range(0, len(w1)): if w1[i] in w2: counter = counter + 1 if counter == len(w1): a = True else: a = False return a print ask5('ana', 'paranoma') print ask5('abc', '123456789a') print '---------------------new def----------------------' def ask6(w1,w2): l1 = [] if w1 in w2: a=True for i in range(0,len(w2) - len(w1) + 1): if w1 == w2[i:len(w1)+i]: pos = i l1.extend([a,pos]) else: a=False l1 = [a,-1] return l1 print ask6('test','ictestinq') print ask6('abc', 'z') print '---------------------new def----------------------' def ask7(w): s = '' for i in w: if i in 'aeuiyo': # pernane ta fonienta if i not in s: # kovo ta dipla s = s + i return s ss = ask7('apaokaaaaoooo') print ss print '---------------------new def----------------------' def diakrita(query,up_limit): c = 0 for i in range(0, up_limit+1): if query in str(i): c = c + 1 return c print diakrita('5',999) #posoi arithmoi exoun toulaxiston ena 5