mes
This commit is contained in:
parent
cd18736cfa
commit
d6e54f42b2
52
pisomka/testovanie.py
Normal file
52
pisomka/testovanie.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
def pocet_samohlasok(text):
|
||||||
|
samohlasky = "aeyuio"
|
||||||
|
counter = 0
|
||||||
|
for i in text.lower():
|
||||||
|
if i in samohlasky:
|
||||||
|
counter +=1
|
||||||
|
return counter
|
||||||
|
|
||||||
|
def najdlhsie_slovo(veta):
|
||||||
|
slova = veta.split()
|
||||||
|
najdlshie = ""
|
||||||
|
for slovo in slova:
|
||||||
|
if len(slovo) > len(najdlshie):
|
||||||
|
najdlshie = slovo
|
||||||
|
return najdlshie
|
||||||
|
|
||||||
|
def striedaj_velkost(text):
|
||||||
|
result = ""
|
||||||
|
for i, znak in enumerate(text):
|
||||||
|
if i % 2 == 0:
|
||||||
|
result.append(znak.upper())
|
||||||
|
else:
|
||||||
|
result.append(znak.lower())
|
||||||
|
return result
|
||||||
|
|
||||||
|
def sucet_parnych(cisla):
|
||||||
|
parni = []
|
||||||
|
for cislo in cisla:
|
||||||
|
if cislo % 2 == 0:
|
||||||
|
parni.append(cislo)
|
||||||
|
suma = sum(parni)
|
||||||
|
return suma
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def bez_duplikatov(cisla):
|
||||||
|
duplikaty = []
|
||||||
|
for cislo in cisla:
|
||||||
|
if cislo not in duplikaty:
|
||||||
|
duplikaty.append(cislo)
|
||||||
|
return duplikaty
|
||||||
|
|
||||||
|
def frekvencia(text):
|
||||||
|
vysledok = {}
|
||||||
|
for znak in text:
|
||||||
|
if znak in vysledok:
|
||||||
|
vysledok[znak] +=1
|
||||||
|
else:
|
||||||
|
vysledok[znak] = 1
|
||||||
|
return vysledok
|
||||||
|
|
||||||
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
def two_fer(name ='teba'):
|
def two_fer(name ='teba'):
|
||||||
if not name:
|
if not name:
|
||||||
name = 'teba'
|
name = 'teba'
|
||||||
return f'Jeden pre {name}, jeden pre mňa
|
return f'Jeden pre {name}, jeden pre mňa'
|
||||||
|
print(two_fer("Janka"))
|
||||||
19
u7/hash_table.py
Normal file
19
u7/hash_table.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
class HashTable:
|
||||||
|
def __init__(self, capacity=10):
|
||||||
|
if type(capacity) is not int:
|
||||||
|
raise TypeError("Kapacita musí byť celé číslo (int)")
|
||||||
|
if capacity <= 0:
|
||||||
|
raise ValueError("Kapacita musí byť kladné číslo")
|
||||||
|
self.__capacity = capacity
|
||||||
|
self._size = 0
|
||||||
|
|
||||||
|
self.empty = object()
|
||||||
|
self.deleted = object()
|
||||||
|
self.slots = [self.empty] * self.__capacity
|
||||||
|
|
||||||
|
@property
|
||||||
|
def capacity(self):
|
||||||
|
return self.__capacity
|
||||||
|
def _check_key(self, key):
|
||||||
|
if not isinstance(key, str):
|
||||||
|
raise TypeError("Kľúč musí byť reťazec (str)")
|
||||||
Loading…
Reference in New Issue
Block a user