From d192fa093e8b5e11e214dd3d02b67a312ab1b1d9 Mon Sep 17 00:00:00 2001 From: s45153 Date: Sun, 19 Nov 2017 15:42:56 +0100 Subject: [PATCH] cw_1_pierwsze_proby --- labs02/task01.py | 35 +++++++++++++++++++++++++++++++++-- labs02/task10.py | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/labs02/task01.py b/labs02/task01.py index 7c08c56..db88b75 100644 --- a/labs02/task01.py +++ b/labs02/task01.py @@ -4,16 +4,47 @@ """ Zad 2. Napisz funkcję even_elements zwracającą listę, 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): - 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): inputs = [[[1, 2, 3, 4, 5, 6]], [[]], [[41]]] outputs = [[1, 3, 5], [], [41]] + + + + for input, output in zip(inputs, outputs): if f(*input) != output: return "ERROR: {}!={}".format(f(*input), output) diff --git a/labs02/task10.py b/labs02/task10.py index f380f0a..58d40d2 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -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):