forked from tdwojak/Python2018
in progres
This commit is contained in:
parent
41207a9a35
commit
1bf2836b87
@ -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,16 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def days_in_year(days):
|
def days_in_year(days):
|
||||||
pass
|
days_in_year=0
|
||||||
|
if days % 4 == 0 and days % 100 != 0 or days % 400 == 0:
|
||||||
|
days_in_year = 366
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
days_in_year = 365
|
||||||
|
|
||||||
|
return days_in_year
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||||
|
@ -13,7 +13,10 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
|
|||||||
|
|
||||||
|
|
||||||
def oov(text, vocab):
|
def oov(text, vocab):
|
||||||
pass
|
test = text.split(' ')
|
||||||
|
words = set()
|
||||||
|
words = {word for word in test if word not in vocab}
|
||||||
|
return words
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,10 @@ 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
|
if n < 1:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return sum(i for i in range(1, n+1))
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -8,9 +8,9 @@ dwoma punktami przestrzeni trójwymiarowej. Punkty są dane jako
|
|||||||
trzyelementowe listy liczb zmiennoprzecinkowych.
|
trzyelementowe listy liczb zmiennoprzecinkowych.
|
||||||
np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
||||||
"""
|
"""
|
||||||
|
import math as m
|
||||||
def euclidean_distance(x, y):
|
def euclidean_distance(x, y):
|
||||||
pass
|
return m.sqrt(sum((i-j)**2 for i,j in zip(x,y)))
|
||||||
|
|
||||||
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,11 @@ 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:
|
||||||
|
big_no= "N" + "O" * n + "!"
|
||||||
|
return big_no
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[5], [6], [2]]
|
inputs = [[5], [6], [2]]
|
||||||
|
@ -6,7 +6,9 @@ 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
|
z = list(text)
|
||||||
|
lista = [ord(x) for x in z]
|
||||||
|
return sum(lista)
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [["this is a string"], ["this is another string"]]
|
inputs = [["this is a string"], ["this is another string"]]
|
||||||
|
@ -6,8 +6,17 @@ Napisz funkcję sum_div35(n), która zwraca sumę wszystkich liczb podzielnych
|
|||||||
przez 3 lub 5 mniejszych niż n.
|
przez 3 lub 5 mniejszych niż n.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_div35(n):
|
def sum_div35(n) :
|
||||||
pass
|
|
||||||
|
suma = 0
|
||||||
|
|
||||||
|
for i in range(n) :
|
||||||
|
|
||||||
|
if i % 3 == 0 or i % 5 == 0:
|
||||||
|
|
||||||
|
suma += i
|
||||||
|
|
||||||
|
return suma
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
|
@ -9,7 +9,15 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
pass
|
slownik = {'e' : '3', 'l' : '1', 'o' : '0', 't' : '7'}
|
||||||
|
|
||||||
|
for a in text:
|
||||||
|
|
||||||
|
if a in slownik:
|
||||||
|
|
||||||
|
text = text.replace(a, slownik [a])
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,7 +9,15 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
|||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
pass
|
result = []
|
||||||
|
|
||||||
|
for i in range(len(text)):
|
||||||
|
if i % 2 == 0:
|
||||||
|
result.append(text[i].upper())
|
||||||
|
else:
|
||||||
|
result.append(text[i])
|
||||||
|
|
||||||
|
return ''.join(result)
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
Loading…
Reference in New Issue
Block a user