1
0
forked from tdwojak/Python2018

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	labs02/task08.py
This commit is contained in:
s407545 2018-06-03 11:15:26 +02:00
commit b5dbb6ca08
5 changed files with 60 additions and 6 deletions

View File

@ -7,7 +7,15 @@ przez 3 lub 5 mniejszych niż n.
"""
def sum_div35(n):
if n == 0:
return 0
else:
suma=0
for i in range(n):
if ((i%3) == 0) or ((i%5) == 0):
suma =suma + i
return suma
def tests(f):
inputs = [[10], [100], [3845]]

View File

@ -7,10 +7,18 @@ na podobnie wyglądające cyfry: 'e' na '3', 'l' na '1', 'o' na '0', 't' na '7'.
Np. leet('leet') powinno zwrócić '1337'.
"""
def leet_speak(text):
pass
for i in range(len(text)):
if ((text[i]) == 'e'):
text = text[:i] + '3' + text[i + 1:]
elif ((text[i]) == 'l'):
text = text[:i] + '1' + text[i + 1:]
elif ((text[i]) == 'o'):
text = text[:i] + '0' + text[i + 1:]
elif ((text[i]) == 't'):
text = text[:i] + '7' + text[i + 1:]
return text
def tests(f):
inputs = [['leet'], ['do not want']]

View File

@ -9,8 +9,12 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text):
pass
for i in range(len(text)):
if ((i % 2) == 0):
text = text[:i] + (text[i].upper()) + text[i + 1:]
return text
def tests(f):
inputs = [['pokemon'], ['do not want'], ['POKEMON']]

View File

@ -9,7 +9,24 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
def common_chars(string1, string2):
pass
n= string1
m= string2
li = []
if len(n) >= len(m):
for i in range(len(n)):
for j in range(len(m)):
if n[i] == m[j]:
li.append(n[i])
else:
for i in range(len(m)):
for j in range(len(n)):
if m[i] == n[j]:
li.append(m[i])
li = list(set(li))
li.remove(' ')
li.sort()
return li
def tests(f):

17
labs04/cw5.py Normal file
View File

@ -0,0 +1,17 @@
import glob
sciezka = "/scores/model.iter*.npz.bleu"
for file in glob.glob(sciezka):
with open(file, 'r') as plik:
for line in plik.readlines():
bleu = float(line[line.find("=")+ 1:line.find(",")])
if bleu >0:
max = bleu
maxi = file
plik.close()
print ( maxi )