forked from tdwojak/Python2018
zadanie domowe 01
This commit is contained in:
parent
e6d22c2701
commit
4644358dc0
@ -6,7 +6,11 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
||||
sumę kodów ASCII znaków.
|
||||
"""
|
||||
def char_sum(text):
|
||||
pass
|
||||
suma = 0
|
||||
for x in text:
|
||||
suma = suma + ord(x)
|
||||
return suma
|
||||
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string"], ["this is another string"]]
|
||||
|
@ -7,7 +7,15 @@ przez 3 lub 5 mniejszych niż 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):
|
||||
inputs = [[10], [100], [3845]]
|
||||
|
@ -9,7 +9,11 @@ Np. leet('leet') powinno zwrócić '1337'.
|
||||
|
||||
|
||||
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):
|
||||
|
@ -9,7 +9,15 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||
|
||||
|
||||
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):
|
||||
|
@ -9,7 +9,17 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
||||
"""
|
||||
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user