forked from tdwojak/Python2017
ćwiczenia 1
This commit is contained in:
parent
d5755b6965
commit
47b7c62adf
@ -7,8 +7,9 @@ która zawiera tylko elementy z list o parzystych indeksach.
|
||||
"""
|
||||
|
||||
def even_elements(lista):
|
||||
pass
|
||||
return lista[::2]
|
||||
|
||||
print(even_elements([1,2,3,4]))
|
||||
|
||||
def tests(f):
|
||||
inputs = [[[1, 2, 3, 4, 5, 6]], [[]], [[41]]]
|
||||
|
@ -6,7 +6,13 @@
|
||||
"""
|
||||
|
||||
def days_in_year(days):
|
||||
pass
|
||||
if (days % 4 == 0 and days % 100 != 0) or days % 400 == 0:
|
||||
return 366
|
||||
else:
|
||||
return 365
|
||||
|
||||
|
||||
print("dni:",days_in_year(2000))
|
||||
|
||||
def tests(f):
|
||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||
|
@ -10,11 +10,21 @@ znakowy i lista łańuchów znakowych. Wszystkie wyrazy należy zmienić na mał
|
||||
litery. (OOV = out of vocabulary) (W pythonie istnieje struktura danych tak
|
||||
jak 'set', która przechowuje elementy bez powtórzeń.)
|
||||
"""
|
||||
"""
|
||||
a = []
|
||||
text = "dom dla lalek"
|
||||
a = text.split(' ')
|
||||
print(a[1])
|
||||
"""
|
||||
def oov(text,vocab):
|
||||
b = set()
|
||||
a = text.split(' ')
|
||||
for wyr in a:
|
||||
if wyr not in vocab:
|
||||
b.add(wyr)
|
||||
return b
|
||||
|
||||
|
||||
def oov(text, vocab):
|
||||
pass
|
||||
|
||||
print(oov("Dom dla kasia", "lalek dom"))
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -7,7 +7,15 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
||||
"""
|
||||
|
||||
def sum_from_one_to_n(n):
|
||||
pass
|
||||
sum=0
|
||||
if n < 1:
|
||||
return 0
|
||||
else:
|
||||
for i in range(n+1):
|
||||
sum+=i
|
||||
return sum
|
||||
|
||||
print(sum_from_one_to_n(3))
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -13,7 +13,7 @@ def pokemon_speak(text):
|
||||
|
||||
|
||||
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):
|
||||
|
@ -6,7 +6,7 @@ def suma(a, b):
|
||||
"""
|
||||
Napisz funkcję, która zwraca sumę elementów.
|
||||
"""
|
||||
pass
|
||||
return a +b
|
||||
|
||||
def tests(f):
|
||||
inputs = [(2, 3), (0, 0), (1, 1)]
|
||||
|
Loading…
Reference in New Issue
Block a user