Upload files to 'homework'
This commit is contained in:
parent
95733aa1aa
commit
cb16eadda1
@ -6,7 +6,17 @@ 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_ascii = 0
|
||||||
|
lista_ascii = []
|
||||||
|
# lista_znaków = list(text)
|
||||||
|
for znak in text:
|
||||||
|
znak_ascii = ord(znak)
|
||||||
|
lista_ascii.append(znak_ascii)
|
||||||
|
for znak2 in lista_ascii:
|
||||||
|
suma_ascii = suma_ascii + znak2
|
||||||
|
return suma_ascii
|
||||||
|
# print('suma ASCII: ', suma_ascii)
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [["this is a string"], ["this is another string"]]
|
inputs = [["this is a string"], ["this is another string"]]
|
||||||
|
@ -7,7 +7,15 @@ przez 3 lub 5 mniejszych niż n.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_div35(n):
|
def sum_div35(n):
|
||||||
pass
|
lista_wejsciowa = range(n)
|
||||||
|
lista_wyjsciowa = []
|
||||||
|
suma = 0
|
||||||
|
for i in lista_wejsciowa:
|
||||||
|
if i % 3 == 0 or i % 5 == 0:
|
||||||
|
lista_wyjsciowa.append(i)
|
||||||
|
for j in lista_wyjsciowa:
|
||||||
|
suma = suma + j
|
||||||
|
return suma
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
@ -21,4 +29,3 @@ def tests(f):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(tests(sum_div35))
|
print(tests(sum_div35))
|
||||||
|
|
||||||
|
@ -9,8 +9,23 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
pass
|
strin = []
|
||||||
|
for znak in text:
|
||||||
|
if znak == 'e':
|
||||||
|
znak1 = '3'
|
||||||
|
strin.append(znak1)
|
||||||
|
elif znak == 'l':
|
||||||
|
znak1 = '1'
|
||||||
|
strin.append(znak1)
|
||||||
|
elif znak == 'o':
|
||||||
|
znak1 = '0'
|
||||||
|
strin.append(znak1)
|
||||||
|
elif znak == 't':
|
||||||
|
znak1 = '7'
|
||||||
|
strin.append(znak1)
|
||||||
|
else:
|
||||||
|
strin.append(znak)
|
||||||
|
return ''.join(strin)
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [['leet'], ['do not want']]
|
inputs = [['leet'], ['do not want']]
|
||||||
|
@ -9,7 +9,15 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
|||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
pass
|
i = 0
|
||||||
|
new_string = []
|
||||||
|
for j in text:
|
||||||
|
if i % 2 == 0:
|
||||||
|
new_string.append(j.upper())
|
||||||
|
else:
|
||||||
|
new_string.append(j)
|
||||||
|
i = i + 1
|
||||||
|
return ''.join(new_string)
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,8 +9,24 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def common_chars(string1, string2):
|
def common_chars(string1, string2):
|
||||||
pass
|
output_list1 = []
|
||||||
|
output_list2 = []
|
||||||
|
for j in string1:
|
||||||
|
if j in string2:
|
||||||
|
output_list1.append(j)
|
||||||
|
#print(output_list1)
|
||||||
|
for i in output_list1:
|
||||||
|
if i not in output_list2:
|
||||||
|
output_list2.append(i)
|
||||||
|
for k in output_list2:
|
||||||
|
if k == ' ':
|
||||||
|
output_list2.remove(k)
|
||||||
|
#return output_list2
|
||||||
|
output_list3 = sorted(output_list2)
|
||||||
|
#print(output_list3)
|
||||||
|
return output_list3
|
||||||
|
|
||||||
|
#common_chars("this is a string", "ala ma kota")
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [["this is a string", "ala ma kota"]]
|
inputs = [["this is a string", "ala ma kota"]]
|
||||||
|
Loading…
Reference in New Issue
Block a user