1
0
forked from tdwojak/Python2017

Updated task files

This commit is contained in:
Kamil 2017-11-23 17:47:55 +01:00
parent 7ddeb4d38c
commit 121db08b43
6 changed files with 37 additions and 7 deletions

View File

@ -11,8 +11,10 @@ ma być zwracany napis "It's not a Big 'No!'".
def big_no(n): def big_no(n):
if n < 5: if n < 5:
return "It's not a Big 'No!" return "It's not a Big 'No!'"
new = n.split('N') else:
o_creater = 'O'*n
return 'N'+o_creater+'!'
def tests(f): def tests(f):
inputs = [[5], [6], [2]] inputs = [[5], [6], [2]]

View File

@ -6,7 +6,11 @@ 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 suma = 0
for n in text:
asco = ord(n)
suma += asco
return suma
def tests(f): def tests(f):
inputs = [["this is a string"], ["this is another string"]] inputs = [["this is a string"], ["this is another string"]]

View File

@ -7,7 +7,15 @@ przez 3 lub 5 mniejszych niż n.
""" """
def sum_div35(n): def sum_div35(n):
pass new_range = range(n)
new_list = []
suma = 0
for n in new_range:
if n % 3 == 0 or n % 5 == 0:
new_list.append(n)
for x in new_list:
suma += x
return suma
def tests(f): def tests(f):
inputs = [[10], [100], [3845]] inputs = [[10], [100], [3845]]

View File

@ -9,7 +9,11 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text): def leet_speak(text):
pass let_dict = {'e': 3, 'l': 1, 'o': 0, 't': 7}
for n in text:
if n in let_dict:
x = let_dict[n]
return text
def tests(f): def tests(f):

View File

@ -9,7 +9,16 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text): def pokemon_speak(text):
pass text_list = []
i = 0
while i != len(text):
text_list.append(text[i].upper())
i += 1
if i != len(text):
text_list.append(text[i])
i += 1
text_list_joined = ''.join(text_list)
return text_list_joined
def tests(f): def tests(f):

View File

@ -9,7 +9,10 @@ Oba napisy będą składać się wyłacznie z małych liter.
""" """
def common_chars(string1, string2): def common_chars(string1, string2):
pass string1_list = set([n for n in string1 if n != ' '])
string2_list = set([n for n in string2 if n != ' '])
common_letter_list = sorted([n for n in string1_list if n in string2_list and n != ' '])
return common_letter_list
def tests(f): def tests(f):