forked from tdwojak/Python2017
cw_1_pierwsze_proby
This commit is contained in:
parent
bd9ffb843a
commit
d192fa093e
@ -4,16 +4,47 @@
|
|||||||
"""
|
"""
|
||||||
Zad 2. Napisz funkcję even_elements zwracającą listę,
|
Zad 2. Napisz funkcję even_elements zwracającą listę,
|
||||||
która zawiera tylko elementy z list o parzystych indeksach.
|
która zawiera tylko elementy z list o parzystych indeksach.
|
||||||
|
== identyczne
|
||||||
|
!= rozne
|
||||||
|
and
|
||||||
|
or (malymi literami)
|
||||||
"""
|
"""
|
||||||
|
lista = [5, 7, 9, 0, 10]
|
||||||
def even_elements(lista):
|
def even_elements(lista):
|
||||||
pass
|
for i in lista:
|
||||||
|
id = lista.index()
|
||||||
|
if id %2==0:
|
||||||
|
print('parzyste indeksy', even_elements(id))
|
||||||
|
|
||||||
|
l = [99, 44, 33]
|
||||||
|
print(l.index(44))
|
||||||
|
|
||||||
|
def find_element_in_list(element, list_element):
|
||||||
|
try:
|
||||||
|
index_element = list_element.index(element)
|
||||||
|
return index_element
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
lista = [5, 7, 9, 0, 10]
|
||||||
|
id = lista.index("5")
|
||||||
|
print("lista",[id])
|
||||||
|
|
||||||
|
|
||||||
|
testlist = [1,2,3,5,3,1,2,1,6]
|
||||||
|
for id, value in enumerate(testlist):
|
||||||
|
if id == 3:
|
||||||
|
print(testlist[id])
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[[1, 2, 3, 4, 5, 6]], [[]], [[41]]]
|
inputs = [[[1, 2, 3, 4, 5, 6]], [[]], [[41]]]
|
||||||
outputs = [[1, 3, 5], [], [41]]
|
outputs = [[1, 3, 5], [], [41]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for input, output in zip(inputs, outputs):
|
for input, output in zip(inputs, outputs):
|
||||||
if f(*input) != output:
|
if f(*input) != output:
|
||||||
return "ERROR: {}!={}".format(f(*input), output)
|
return "ERROR: {}!={}".format(f(*input), output)
|
||||||
|
@ -13,7 +13,7 @@ def pokemon_speak(text):
|
|||||||
|
|
||||||
|
|
||||||
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):
|
||||||
|
Loading…
Reference in New Issue
Block a user