forked from tdwojak/Python2018
Zadanie domowe
This commit is contained in:
parent
6c10fb4b03
commit
c4cf32a7f8
@ -6,7 +6,10 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
||||
sumę kodów ASCII znaków.
|
||||
"""
|
||||
def char_sum(text):
|
||||
pass
|
||||
sum = 0
|
||||
for x in text:
|
||||
sum += ord(x)
|
||||
return sum
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string"], ["this is another string"]]
|
||||
|
@ -7,7 +7,11 @@ przez 3 lub 5 mniejszych niż 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):
|
||||
inputs = [[10], [100], [3845]]
|
||||
|
@ -9,8 +9,13 @@ Np. leet('leet') powinno zwrócić '1337'.
|
||||
|
||||
|
||||
def leet_speak(text):
|
||||
pass
|
||||
|
||||
slownik = {'e':'3', 'l':'1', 'o':'0', 't':'7'}
|
||||
napis = ''
|
||||
for i in text:
|
||||
if i in slownik:
|
||||
napis += slownik[i]
|
||||
else: napis += i
|
||||
return napis
|
||||
|
||||
def tests(f):
|
||||
inputs = [['leet'], ['do not want']]
|
||||
|
@ -9,7 +9,15 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||
|
||||
|
||||
def pokemon_speak(text):
|
||||
pass
|
||||
a = 0
|
||||
napis = ''
|
||||
for i in text:
|
||||
a += 1
|
||||
if a%2 == 1:
|
||||
i = i.upper()
|
||||
else: i
|
||||
napis += i
|
||||
return napis
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -9,7 +9,15 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
||||
"""
|
||||
|
||||
def common_chars(string1, string2):
|
||||
pass
|
||||
lista = []
|
||||
str1 = set(string1)
|
||||
str2 = set(string2)
|
||||
for i in str1:
|
||||
for j in str2:
|
||||
if i == j and i != ' ':
|
||||
lista += i
|
||||
lista.sort()
|
||||
return lista
|
||||
|
||||
|
||||
def tests(f):
|
||||
@ -23,4 +31,4 @@ def tests(f):
|
||||
return "TESTS PASSED"
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(tests(common_chars))
|
||||
print(tests(common_chars))
|
16
labs04/05.py
Normal file
16
labs04/05.py
Normal file
@ -0,0 +1,16 @@
|
||||
import glob
|
||||
import os
|
||||
|
||||
max_wartosc_bleu = 0
|
||||
max_nazwa_pliku =''
|
||||
for nazwa_pliku in glob.glob('scores/*'):
|
||||
with open(nazwa_pliku, 'r') as plik:
|
||||
for linia in plik.readlines():
|
||||
wartosc_bleu = linia.split(' ')[2]
|
||||
wartosc_bleu = float(wartosc_bleu.strip(','))
|
||||
if wartosc_bleu > max_wartosc_bleu:
|
||||
max_wartosc_bleu = wartosc_bleu
|
||||
max_nazwa_pliku = nazwa_pliku
|
||||
|
||||
print(max_nazwa_pliku)
|
||||
|
Loading…
Reference in New Issue
Block a user