Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
1.3 kB
2
Indexable
Never
with open ("tekst.txt") as plik:
    slowa = plik.read().split()
def jeden():
    wynik = 0
    for slowo in slowa:
        for i in range(len(slowo) - 1):
            if slowo[i] == slowo[i+1]:
                wynik += 1
                break
    print(wynik)

def dwa():
    suma = 0
    tab = []
    procenty = []
    for i in range(26):
        tab.append(0)
    for slowo in slowa:
        for i in range(len(slowo)):
            tab[ord(slowo[i]) - 65] += 1
    for i in range(len(tab)):
        suma += tab[i]
    for i in range(len(tab)):
        procenty.append(round((tab[i] / suma) * 100, 2))
        print(chr(i+65), tab[i], procenty[i], "%")

def trzy():
    samogloski = "AEIOUY"
    max = 0
    ile_max = 0
    max_slowo = ""
    obecna = 0
    for slowo in slowa:
        for litera in slowo:
            if litera in samogloski:
                obecna = 0
            else:
                obecna += 1
                if obecna == max:
                    ile_max += 1
                elif obecna >= max:
                    max_slowo = slowo
                    ile_max = 1
                    max = obecna
        obecna = 0
    print("pierwsze", max_slowo,"dlugosc_ciagu", max,"ilosc_takich_ciagow", ile_max)
trzy()
Leave a Comment