forked from tdwojak/Python2017
update all tasks
This commit is contained in:
parent
2d671ed2d6
commit
fc40cd3b02
@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def even_elements(lista):
|
def even_elements(lista):
|
||||||
pass
|
return lista[::2]
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def days_in_year(days):
|
def days_in_year(days):
|
||||||
pass
|
if days % 4 == 0 and days % 100 != 0 or days % 400 == 0:
|
||||||
|
return 366
|
||||||
|
else:
|
||||||
|
return 365
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||||
|
@ -13,7 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
|
|||||||
|
|
||||||
|
|
||||||
def oov(text, vocab):
|
def oov(text, vocab):
|
||||||
pass
|
wynik = set()
|
||||||
|
for wyraz in text.split(' '):
|
||||||
|
if wyraz.lower() not in vocab:
|
||||||
|
wynik.add(wyraz.lower())
|
||||||
|
return wynik
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,13 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_from_one_to_n(n):
|
def sum_from_one_to_n(n):
|
||||||
pass
|
wynik = 0
|
||||||
|
if n < 1:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
for i in range(n):
|
||||||
|
wynik += (i+1)
|
||||||
|
return wynik
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -10,7 +10,7 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def euclidean_distance(x, y):
|
def euclidean_distance(x, y):
|
||||||
pass
|
return ((x[0]-y[0])**2 + (x[1]-y[1])**2 + (x[2]-y[2])**2)**0.5
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
||||||
|
@ -10,7 +10,10 @@ ma być zwracany napis "It's not a Big 'No!'".
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def big_no(n):
|
def big_no(n):
|
||||||
pass
|
if n < 5:
|
||||||
|
return "It's not a Big 'No!'"
|
||||||
|
else:
|
||||||
|
return "N" + n*"O" + "!"
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[5], [6], [2]]
|
inputs = [[5], [6], [2]]
|
||||||
|
@ -6,7 +6,10 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
|||||||
sumę kodów ASCII znaków.
|
sumę kodów ASCII znaków.
|
||||||
"""
|
"""
|
||||||
def char_sum(text):
|
def char_sum(text):
|
||||||
pass
|
wynik = 0
|
||||||
|
for litera in text:
|
||||||
|
wynik += ord(litera)
|
||||||
|
return wynik
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [["this is a string"], ["this is another string"]]
|
inputs = [["this is a string"], ["this is another string"]]
|
||||||
|
@ -7,7 +7,14 @@ przez 3 lub 5 mniejszych niż n.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_div35(n):
|
def sum_div35(n):
|
||||||
pass
|
wynik = 0
|
||||||
|
if n<0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
for i in range(n):
|
||||||
|
if i % 3 == 0 or i % 5 == 0:
|
||||||
|
wynik += i
|
||||||
|
return wynik
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
|
@ -9,7 +9,18 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
pass
|
text = text.lower()
|
||||||
|
text = text.replace('o', '0')
|
||||||
|
text = text.replace('l', '1')
|
||||||
|
text = text.replace('z', '2')
|
||||||
|
text = text.replace('e', '3')
|
||||||
|
text = text.replace('h', '4')
|
||||||
|
text = text.replace('s', '5')
|
||||||
|
text = text.replace('g', '6')
|
||||||
|
text = text.replace('t', '7')
|
||||||
|
text = text.replace('b', '8')
|
||||||
|
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,11 +9,20 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
|||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
pass
|
wynik = []
|
||||||
|
indeks = 0
|
||||||
|
for litera in text:
|
||||||
|
if indeks % 2 == 0:
|
||||||
|
wynik.append(litera.upper())
|
||||||
|
else:
|
||||||
|
wynik.append(litera)
|
||||||
|
indeks += 1
|
||||||
|
|
||||||
|
return ''.join(wynik)
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [['pokemon'], ['do not want'], 'POKEMON']
|
inputs = [['pokemon'], ['do not want'], ['POKEMON']]
|
||||||
outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON']
|
outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON']
|
||||||
|
|
||||||
for input, output in zip(inputs, outputs):
|
for input, output in zip(inputs, outputs):
|
||||||
|
@ -9,7 +9,13 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def common_chars(string1, string2):
|
def common_chars(string1, string2):
|
||||||
pass
|
common = []
|
||||||
|
for lit in string1:
|
||||||
|
if lit in string2 and lit != ' ':
|
||||||
|
common.append(lit)
|
||||||
|
common = list(set(common))
|
||||||
|
common.sort()
|
||||||
|
return common
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
Loading…
Reference in New Issue
Block a user