task 05-10
This commit is contained in:
parent
bfde5771a7
commit
d6f4abe562
@ -10,8 +10,12 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def euclidean_distance(x, y):
|
def euclidean_distance(x, y):
|
||||||
d= math.pow(x) + math.pow(y)
|
counter = 0
|
||||||
distance = math.sqrt(d)
|
for i in range(len(x)):
|
||||||
|
d= math.pow(x[i] - y[i],2)
|
||||||
|
counter += d
|
||||||
|
distance = math.sqrt(counter)
|
||||||
|
return distance
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
||||||
|
@ -10,7 +10,11 @@ ma być zwracany napis "It's not a Big 'No!'".
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def big_no(n):
|
def big_no(n):
|
||||||
pass
|
if n < 5:
|
||||||
|
return "It's not a Big 'No!'"
|
||||||
|
else:
|
||||||
|
big_no = "N" + "O" * n + "!"
|
||||||
|
return big_no
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[5], [6], [2]]
|
inputs = [[5], [6], [2]]
|
||||||
|
@ -6,7 +6,9 @@ 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
|
a = list(text)
|
||||||
|
lista = [ord(x) for x in a]
|
||||||
|
return sum(lista)
|
||||||
|
|
||||||
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,14 @@ przez 3 lub 5 mniejszych niż n.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_div35(n):
|
def sum_div35(n):
|
||||||
pass
|
suma = 0
|
||||||
|
|
||||||
|
for i in range(n) :
|
||||||
|
if i % 3 == 0 or i % 5 == 0:
|
||||||
|
suma += i
|
||||||
|
|
||||||
|
return suma
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
|
@ -9,7 +9,17 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
pass
|
lista = list(text)
|
||||||
|
słownik = {'1':'l', '3':'e', '0':'o', '7':'t'}
|
||||||
|
lista_wartosci = słownik.values()
|
||||||
|
lista_mod = []
|
||||||
|
|
||||||
|
for i in range(len(lista)):
|
||||||
|
for key, value in słownik.items():
|
||||||
|
if lista[i] in value:
|
||||||
|
lista[i]=key
|
||||||
|
wynik = "".join(lista)
|
||||||
|
return wynik
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,7 +9,10 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
|||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
pass
|
lista = list(text)
|
||||||
|
lista[::2].capitalize()
|
||||||
|
wynik = "".join(lista)
|
||||||
|
return wynik
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
Loading…
Reference in New Issue
Block a user