1
0
Fork 0

update all tasks

This commit is contained in:
s45160 2017-11-19 15:44:36 +01:00
parent 2d671ed2d6
commit fc40cd3b02
11 changed files with 65 additions and 12 deletions

View File

@ -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):

View File

@ -6,7 +6,10 @@
"""
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):
inputs = [[2015], [2012], [1900], [2400], [1977]]

View File

@ -13,7 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
def oov(text, vocab):
pass
wynik = set()
for wyraz in text.split(' '):
if wyraz.lower() not in vocab:
wynik.add(wyraz.lower())
return wynik

View File

@ -7,7 +7,13 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
"""
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):

View File

@ -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):
pass
return ((x[0]-y[0])**2 + (x[1]-y[1])**2 + (x[2]-y[2])**2)**0.5
def tests(f):
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]

View File

@ -10,7 +10,10 @@ ma być zwracany napis "It's not a Big 'No!'".
"""
def big_no(n):
pass
if n < 5:
return "It's not a Big 'No!'"
else:
return "N" + n*"O" + "!"
def tests(f):
inputs = [[5], [6], [2]]

View File

@ -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
wynik = 0
for litera in text:
wynik += ord(litera)
return wynik
def tests(f):
inputs = [["this is a string"], ["this is another string"]]

View File

@ -7,7 +7,14 @@ przez 3 lub 5 mniejszych niż 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):
inputs = [[10], [100], [3845]]

View File

@ -9,7 +9,18 @@ Np. leet('leet') powinno zwrócić '1337'.
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):

View File

@ -9,11 +9,20 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
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):
inputs = [['pokemon'], ['do not want'], 'POKEMON']
inputs = [['pokemon'], ['do not want'], ['POKEMON']]
outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON']
for input, output in zip(inputs, outputs):

View File

@ -9,7 +9,13 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
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):