forked from tdwojak/Python2018
laboratoria2
This commit is contained in:
parent
41207a9a35
commit
b60f116f5e
@ -6,7 +6,13 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def days_in_year(days):
|
def days_in_year(days):
|
||||||
pass
|
if ((days % 4 == 0) and (days % 100 != 0)):
|
||||||
|
wynik=366
|
||||||
|
elif (days % 400 == 0):
|
||||||
|
wynik=366
|
||||||
|
else:
|
||||||
|
wynik=365
|
||||||
|
return wynik
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||||
|
@ -13,7 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
|
|||||||
|
|
||||||
|
|
||||||
def oov(text, vocab):
|
def oov(text, vocab):
|
||||||
pass
|
text = text.lower()
|
||||||
|
text2 = text.split(' ')
|
||||||
|
vocab2 = ' '.join(vocab)
|
||||||
|
vocab2 = vocab2.lower()
|
||||||
|
vocab2 = vocab2.split(' ')
|
||||||
|
return (set(text2).difference(set(vocab2)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,13 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_from_one_to_n(n):
|
def sum_from_one_to_n(n):
|
||||||
pass
|
if n<1:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
wynik = 0;
|
||||||
|
for i in range(1,n+1):
|
||||||
|
wynik = wynik+i;
|
||||||
|
return wynik
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -10,7 +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):
|
||||||
pass
|
eukl = 0;
|
||||||
|
for i in range(3):
|
||||||
|
eukl = eukl+(x[i]-y[i])**2
|
||||||
|
eukl = eukl**0.5
|
||||||
|
return eukl
|
||||||
|
|
||||||
|
|
||||||
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,15 @@ ma być zwracany napis "It's not a Big 'No!'".
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def big_no(n):
|
def big_no(n):
|
||||||
pass
|
if n<5:
|
||||||
|
tekst = "It's not a Big 'No!'"
|
||||||
|
else:
|
||||||
|
lista=["N"]
|
||||||
|
for i in range(1,n+1):
|
||||||
|
lista.append("O")
|
||||||
|
lista.append("!")
|
||||||
|
tekst = ''.join(lista)
|
||||||
|
return tekst
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[5], [6], [2]]
|
inputs = [[5], [6], [2]]
|
||||||
|
@ -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 znak in text:
|
||||||
|
suma = suma+ord(znak)
|
||||||
|
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,12 @@ 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%3)==0 or (i%5)==0):
|
||||||
|
suma = suma+i
|
||||||
|
return suma
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
|
@ -9,7 +9,21 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
pass
|
text2=[]
|
||||||
|
for znak in text:
|
||||||
|
if znak == 'e':
|
||||||
|
text2.append('3')
|
||||||
|
elif znak == 'l':
|
||||||
|
text2.append('1')
|
||||||
|
elif znak == 'o':
|
||||||
|
text2.append('0')
|
||||||
|
elif znak == 't':
|
||||||
|
text2.append('7')
|
||||||
|
else:
|
||||||
|
text2.append(znak)
|
||||||
|
text2 = ''.join(text2)
|
||||||
|
return text2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,7 +9,17 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
|||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
pass
|
text1 = []
|
||||||
|
for znak in text:
|
||||||
|
text1.append(znak)
|
||||||
|
text2 =[]
|
||||||
|
for i in range(0, len(text)):
|
||||||
|
if (i%2)==0:
|
||||||
|
text2.append(text1[i].upper())
|
||||||
|
else:
|
||||||
|
text2.append(text1[i])
|
||||||
|
text2 = ''.join(text2)
|
||||||
|
return text2
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,7 +9,13 @@ 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_znaki = set(string1).intersection(set(string2))
|
||||||
|
wspolne_znaki = set(wspolne_znaki).difference(set(' '))
|
||||||
|
wspolne_znaki_tbl = []
|
||||||
|
for znak in wspolne_znaki:
|
||||||
|
wspolne_znaki_tbl.append(znak)
|
||||||
|
wspolne_znaki_tbl.sort()
|
||||||
|
return wspolne_znaki_tbl
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
Loading…
Reference in New Issue
Block a user