forked from tdwojak/Python2018
Zadania 7-11
This commit is contained in:
parent
41207a9a35
commit
c1a510a707
@ -6,7 +6,10 @@ 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 i in text:
|
||||||
|
suma = suma + ord(i)
|
||||||
|
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"]]
|
||||||
|
@ -7,7 +7,11 @@ przez 3 lub 5 mniejszych niż n.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_div35(n):
|
def sum_div35(n):
|
||||||
pass
|
suma = 0
|
||||||
|
for i in range (1, n):
|
||||||
|
if (i % 5 == 0) | (i % 3 == 0):
|
||||||
|
suma = suma + i
|
||||||
|
return suma
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
|
@ -9,8 +9,14 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
pass
|
dict = {'e': '3', 'l': '1', 'o': '0', 't': '7'}
|
||||||
|
text2=""
|
||||||
|
for i in text:
|
||||||
|
if i in dict:
|
||||||
|
text2 += dict[i]
|
||||||
|
else:
|
||||||
|
text2 += i
|
||||||
|
return text2
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [['leet'], ['do not want']]
|
inputs = [['leet'], ['do not want']]
|
||||||
|
@ -7,9 +7,17 @@ Napisz funkcję pokemon_speak, która zamienia w podanym napisie co drugą liter
|
|||||||
na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
pass
|
text2=""
|
||||||
|
b=""
|
||||||
|
a = len(text)
|
||||||
|
for i in range(a):
|
||||||
|
if (i % 2 == 0):
|
||||||
|
b = text[i].upper()
|
||||||
|
text2 += b
|
||||||
|
else:
|
||||||
|
text2 += text[i]
|
||||||
|
return text2
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,8 +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
|
list1=[]
|
||||||
|
for i in string1:
|
||||||
|
if i in string2:
|
||||||
|
list1.append(i)
|
||||||
|
for i in string2:
|
||||||
|
if i in string1:
|
||||||
|
list1.append(i)
|
||||||
|
list1=list(set(list1))
|
||||||
|
list1.sort()
|
||||||
|
list1.pop(0)
|
||||||
|
return list1
|
||||||
|
|
||||||
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