priklady.py 579 Bytes
Newer Older
Mareš Martin's avatar
Mareš Martin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3

def otoc_retezec(r):
    return r[::-1]

def otoc_cislo(x):
    return int(otoc_retezec(str(x)))

def spocitej_slova(radek):
    return len(radek.split())

def spocitej_ruzna_slova(radek):
    slova = []
    for slovo in radek.split():
        if slovo not in slova:
            slova.append(slovo)
    return len(slova)

cermak's avatar
cermak committed
19
20
21
22
# trikove reseni s pouzitim setu
def spocitej_ruzna_slova2(radek):
    return len(set(spocitej_slova(radek)))

Mareš Martin's avatar
Mareš Martin committed
23
24
25
26
27
def vyhodnot_vyraz(vyraz):
    soucet = 0
    for clen in vyraz.split("+"):
        soucet += int(clen)
    return soucet