Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
1a4de39386 | |||
7f4577f327 | |||
f0a92e0f68 | |||
8c082cfeb7 | |||
586ba304cf | |||
513808064f | |||
05f21a640c |
@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach.
|
||||
"""
|
||||
|
||||
def even_elements(lista):
|
||||
pass
|
||||
return lista [::2]
|
||||
|
||||
|
||||
def tests(f):
|
||||
@ -22,4 +22,4 @@ def tests(f):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(tests(even_elements))
|
||||
print(tests(even_elements))
|
@ -6,7 +6,13 @@
|
||||
"""
|
||||
|
||||
def days_in_year(days):
|
||||
pass
|
||||
dni=0
|
||||
if days % 4 == 0 and days % 100 != 0 or days % 400 == 0:
|
||||
dni = 366
|
||||
else:
|
||||
dni = 365
|
||||
|
||||
return dni
|
||||
|
||||
def tests(f):
|
||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||
|
@ -6,7 +6,10 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
||||
sumę kodów ASCII znaków.
|
||||
"""
|
||||
def char_sum(text):
|
||||
pass
|
||||
suma = 0
|
||||
for znak in text:
|
||||
suma = suma + ord(znak)
|
||||
return suma
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string"], ["this is another string"]]
|
||||
|
@ -7,7 +7,12 @@ przez 3 lub 5 mniejszych niż n.
|
||||
"""
|
||||
|
||||
def sum_div35(n):
|
||||
pass
|
||||
suma = 0
|
||||
for liczba in range(n):
|
||||
if (liczba % 3 == 0) or (liczba % 5 == 0):
|
||||
suma = suma + liczba
|
||||
|
||||
return suma
|
||||
|
||||
def tests(f):
|
||||
inputs = [[10], [100], [3845]]
|
||||
@ -22,3 +27,5 @@ def tests(f):
|
||||
if __name__ == "__main__":
|
||||
print(tests(sum_div35))
|
||||
|
||||
|
||||
|
||||
|
@ -9,7 +9,13 @@ Np. leet('leet') powinno zwrócić '1337'.
|
||||
|
||||
|
||||
def leet_speak(text):
|
||||
pass
|
||||
text = str(text)
|
||||
text = text.replace("e","3") # zamienia "e" na "3"
|
||||
text = text.replace("l","1") # "l" na "1"
|
||||
text = text.replace("o","0") # "o" na "0"
|
||||
text = text.replace("t","7") # "t" na "7"
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -9,8 +9,17 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||
|
||||
|
||||
def pokemon_speak(text):
|
||||
pass
|
||||
lista = list(text)
|
||||
wynik = []
|
||||
for slowa in range(len(lista)):
|
||||
if slowa % 2 == 0:
|
||||
wynik.append(lista[slowa].upper())
|
||||
|
||||
else:
|
||||
wynik.append(lista[slowa])
|
||||
|
||||
duze = "".join(wynik)
|
||||
return duze
|
||||
|
||||
def tests(f):
|
||||
inputs = [['pokemon'], ['do not want'], ['POKEMON']]
|
||||
@ -24,3 +33,4 @@ def tests(f):
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(tests(pokemon_speak))
|
||||
|
||||
|
@ -9,7 +9,12 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
||||
"""
|
||||
|
||||
def common_chars(string1, string2):
|
||||
pass
|
||||
s1 = string1.replace(' ','')
|
||||
s2 = string2.replace(' ','')
|
||||
s1=set(s1)
|
||||
s2=set(s2)
|
||||
common = s1 & s2
|
||||
return(sorted(list(common)))
|
||||
|
||||
|
||||
def tests(f):
|
||||
@ -23,4 +28,4 @@ def tests(f):
|
||||
return "TESTS PASSED"
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(tests(common_chars))
|
||||
print(tests(common_chars))
|
Loading…
Reference in New Issue
Block a user