1
0
forked from tdwojak/Python2018

zadanie domowe 01

This commit is contained in:
monika 2018-06-02 21:24:05 +02:00
parent e6d22c2701
commit 4644358dc0
5 changed files with 39 additions and 5 deletions

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 x in text:
suma = suma + ord(x)
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 x = 0
for i in range(1,n):
if i % 15 == 0:
x += i
elif i % 3 == 0:
x += i
elif i % 5 == 0:
x += i
return x
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 text = text.replace('e', '3')
text = text.replace('l', '1')
text = text.replace('o', '0')
text = text.replace('t', '7')
return text
def tests(f): def tests(f):

View File

@ -9,7 +9,15 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text): def pokemon_speak(text):
pass new_text = ''
capitalize = True
for x in text:
if capitalize is True:
new_text += x.upper()
else:
new_text += x
capitalize = not capitalize
return new_text
def tests(f): def tests(f):

View File

@ -9,7 +9,17 @@ Oba napisy będą składać się wyłacznie z małych liter.
""" """
def common_chars(string1, string2): def common_chars(string1, string2):
pass wspolne = []
string1 = string1.replace(' ', '')
string2 = string2.replace(' ', '')
znaki_z_1 = set(string1)
znaki_z_2 = set(string2)
for x in znaki_z_1:
if x in znaki_z_2:
wspolne.append(x)
return sorted(wspolne)
def tests(f): def tests(f):