forked from tdwojak/Python2017
ready for review
This commit is contained in:
parent
cd6b55c938
commit
2386b38ffe
@ -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):
|
||||
|
@ -5,8 +5,15 @@
|
||||
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
|
||||
"""
|
||||
|
||||
def days_in_year(days):
|
||||
pass
|
||||
def days_in_year(year):
|
||||
if year % 4 == 0 and year % 100 == 0 and year % 400 == 0:
|
||||
return 366
|
||||
elif year % 4 == 0 and year % 100 != 0:
|
||||
return 366
|
||||
elif year % 4 == 0 and year % 100 == 0 and year % 400 != 0:
|
||||
return 365
|
||||
else:
|
||||
return 365
|
||||
|
||||
def tests(f):
|
||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||
|
@ -16,7 +16,7 @@ def oov(text, vocab):
|
||||
s=set()
|
||||
for i in text.split():
|
||||
if i not in vocab:
|
||||
text.lower()
|
||||
s.add(i)
|
||||
return s
|
||||
|
||||
|
||||
|
@ -7,7 +7,14 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
||||
"""
|
||||
|
||||
def sum_from_one_to_n(n):
|
||||
pass
|
||||
if n<1:
|
||||
return 0
|
||||
else:
|
||||
x=0
|
||||
for i in range (n+1):
|
||||
x=x+i
|
||||
return x
|
||||
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -9,8 +9,11 @@ trzyelementowe listy liczb zmiennoprzecinkowych.
|
||||
np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def euclidean_distance(x, y):
|
||||
pass
|
||||
dist=((x[0]-y[0])**2+(x[1]-y[1])**2+(x[2]-y[2])**2)**(1/2)
|
||||
return dist
|
||||
|
||||
def tests(f):
|
||||
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
||||
|
@ -10,7 +10,14 @@ 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:
|
||||
tekst="N"
|
||||
for i in range (n):
|
||||
tekst += "O"
|
||||
tekst += "!"
|
||||
return(tekst)
|
||||
|
||||
def tests(f):
|
||||
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.
|
||||
"""
|
||||
def char_sum(text):
|
||||
pass
|
||||
suma=0
|
||||
for i in range (len(text)):
|
||||
suma+=ord(text[i])
|
||||
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 i in range(n):
|
||||
if i%3==0 or i%5==0:
|
||||
suma+=i
|
||||
return(suma)
|
||||
|
||||
|
||||
def tests(f):
|
||||
inputs = [[10], [100], [3845]]
|
||||
|
@ -9,7 +9,7 @@ Np. leet('leet') powinno zwrócić '1337'.
|
||||
|
||||
|
||||
def leet_speak(text):
|
||||
pass
|
||||
return(text.replace("e","3").replace("l", "1").replace("o", "0").replace("t", "7"))
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -9,11 +9,18 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||
|
||||
|
||||
def pokemon_speak(text):
|
||||
pass
|
||||
for i in range(len(text)):
|
||||
if i == 0:
|
||||
mytext=''.join(['', text[i].upper()])
|
||||
elif i % 2 == 0:
|
||||
mytext = ''.join([mytext[:i], text[i].upper()])
|
||||
else:
|
||||
mytext = ''.join([mytext[:i], text[i]])
|
||||
return (mytext)
|
||||
|
||||
|
||||
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):
|
||||
|
@ -9,7 +9,14 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
||||
"""
|
||||
|
||||
def common_chars(string1, string2):
|
||||
pass
|
||||
s=[]
|
||||
s1 = list(set(string1.replace(' ','')))
|
||||
s2 = list(set(string2.replace(' ','')))
|
||||
for i in s1:
|
||||
if i in s2:
|
||||
s.append(i)
|
||||
s.sort()
|
||||
return s
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
Loading…
Reference in New Issue
Block a user