0
0
forked from tdwojak/Python2018

zadania 7-10

This commit is contained in:
s441405 2018-06-02 13:59:58 +02:00
parent 41207a9a35
commit 331db64830
4 changed files with 22 additions and 4 deletions

View File

@ -6,7 +6,7 @@ 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 return sum(ord(i) for i in text)
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,11 @@ przez 3 lub 5 mniejszych niż n.
""" """
def sum_div35(n): def sum_div35(n):
pass sum=0
for i in range(n):
if (i%3 ==0 or i%5 ==0):
sum += i
return(sum)
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,17 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text): def pokemon_speak(text):
pass slowo = list(text)
wynik = []
for i in range(len(slowo)):
if i == 0 or i % 2 == 0:
wynik.append(slowo[i].upper())
else:
wynik.append(slowo[i])
slowo = "".join(wynik)
return slowo
def tests(f): def tests(f):