1
0
forked from tdwojak/Python2017

Compare commits

..

11 Commits

Author SHA1 Message Date
a0fecba5c4 Final updates 2018-01-29 12:22:18 +01:00
26afa652a5 update 2018-01-24 10:26:29 +01:00
f61d161938 update results 2018-01-23 22:34:37 +01:00
5d25e165c4 Update 45163 2018-01-23 22:05:16 +01:00
dc5fb3f34b Add marks 2018-01-23 17:19:50 +01:00
fd67d4b96f Add task06 2018-01-23 16:54:47 +01:00
1599eb71ba update szwedek 2018-01-22 15:42:47 +01:00
524eefe436 Update scores for 45161 2018-01-19 08:50:18 +01:00
7ef244fb88 Fix socres for 147 2018-01-18 17:41:40 +01:00
d8025c91ff Add missed results 2018-01-15 11:11:11 +01:00
378fee7582 Update results 2018-01-11 13:41:08 +01:00
18 changed files with 66 additions and 310 deletions

View File

@ -1,24 +1,38 @@
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11 ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11 | labs03 | labs04 | labs06 | Punkty | Ocena |
---------|-----------------|-----------------|-----------------|-----------------|--------------- ---------|-----------------|-----------------|-----------------|-----------------|-----------------|----------|----------|----------|--------|-------|
s45168 | 0 | 0 | 0 | 0 | 0 s45146 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45162 | 1 | 1 | 1 | 1 | 1 s45147 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45158 | 1 | 1 | 0 | 0 | 1 s45148 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
szwedek | 1 | 1 | 1 | 1 | 1 s45150 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 8 | 16 | 4 |
s45155 | 1 | 1 | 1 | 1 | 1 s45151 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 18 | 4.5 |
s45152 | 1 | 1 | 1 | 0 | 1 s45152 | 1 | 1 | 1 | 0 | 1 | 0 | 5 | 8 | 17 | 4 |
s45148 | 1 | 1 | 1 | 1 | 1 s45153 | 0 | 1 | 1 | 1 | 1 | 4 | 0 | 8 | 16 | 4 |
s45166 | 1 | 1 | 1 | 1 | 1 s45155 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | 8 | 19 | 4.5 |
s45151 | 1 | 1 | 1 | 1 | 1 s45156 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45146 | 1 | 1 | 1 | 1 | 1 s45157 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
s45150 | 1 | 1 | 1 | 1 | 1 s45158 | 1 | 1 | 0 | 0 | 1 | 4 | 5 | 8 | 19 | 4.5 |
s45452 | 1 | 1 | 1 | 1 | 1 s45159 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 8 | 18 | 4.5 |
s45165 | 1 | 1 | 1 | 1 | 1 s45160 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
s45160 | 1 | 1 | 1 | 1 | 1 s45161 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45153 | 0 | 0 | 0 | 0 | 0 s45162 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45156 | 1 | 1 | 1 | 1 | 1 s45163 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
s45157 | 0 | 0 | 1 | 1 | 1 s45164 | 1 | 1 | 0 | 1 | 0 | 0 | 5 | 8 | 16 | 4 |
s45167 | 1 | 1 | 1 | 1 | 1 s45165 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45147 | 1 | 0 | 0 | 1 | 0 s45166 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45159 | 0 | 0 | 0 | 0 | 0 s45167 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 17 | 4 |
s45161 | 1 | 1 | 1 | 1 | 1 s45168 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
s45164 | 1 | 1 | 0 | 1 | 0 s45452 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
szwedek | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 10 | 24 | 5 |
Skala:
Punkty | Ocena |
-------|-------|
24-20 | 5 |
19-18 | 4.5 |
17-16 | 4 |
15-13 | 3 |
12-0 | 2 |
Max: 22

View File

@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach.
""" """
def even_elements(lista): def even_elements(lista):
return(lista[::2]) pass
def tests(f): def tests(f):

View File

@ -5,11 +5,8 @@
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366). Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
""" """
def days_in_year(years): def days_in_year(days):
if (years % 4 == 0 and years % 100 != 0) or years % 400 == 0: pass
return 366
else:
return 365
def tests(f): def tests(f):
inputs = [[2015], [2012], [1900], [2400], [1977]] inputs = [[2015], [2012], [1900], [2400], [1977]]

View File

@ -13,12 +13,7 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
def oov(text, vocab): def oov(text, vocab):
list_of_words = [] pass
text_splitted = text.split(' ')
for word in text_splitted:
if word.lower() not in vocab:
list_of_words.append(word.lower())
return set(list_of_words)

View File

@ -7,14 +7,8 @@ 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):
suma = 0 pass
for i in range(n+1):
suma = suma + i
if n < 1:
return 0
else:
return suma
def tests(f): def tests(f):
inputs = [[999], [-100]] inputs = [[999], [-100]]

View File

@ -8,10 +8,9 @@ dwoma punktami przestrzeni trójwymiarowej. Punkty są dane jako
trzyelementowe listy liczb zmiennoprzecinkowych. trzyelementowe listy liczb zmiennoprzecinkowych.
np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5. np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
""" """
from math import sqrt
def euclidean_distance(x, y):
return sqrt(sum((x - y) ** 2 for x, y in zip(x, y))) def euclidean_distance(x, y):
pass
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)]]

View File

@ -10,11 +10,7 @@ ma być zwracany napis "It's not a Big 'No!'".
""" """
def big_no(n): def big_no(n):
napis = 'N' pass
if n < 5:
return "It's not a Big 'No!'"
else:
return napis + n * 'O' + '!'
def tests(f): def tests(f):
inputs = [[5], [6], [2]] inputs = [[5], [6], [2]]

View File

@ -6,10 +6,7 @@ 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):
suma = 0 pass
for c in text:
suma += ord(c)
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"]]

View File

@ -7,12 +7,7 @@ przez 3 lub 5 mniejszych niż n.
""" """
def sum_div35(n): def sum_div35(n):
suma = 0 pass
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]]

View File

@ -9,16 +9,8 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text): def leet_speak(text):
slownik = {'e':3, 'l':1, 'o':0, 't':7} pass
dekod = ''
for znak in text:
if znak in slownik:
dekod += str(slownik[znak])
else:
dekod += znak
return dekod
def tests(f): def tests(f):
inputs = [['leet'], ['do not want']] inputs = [['leet'], ['do not want']]

View File

@ -9,16 +9,8 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text): def pokemon_speak(text):
wynik = '' pass
switch = 1
for znak in text:
if switch == 1:
wynik += znak.upper()
switch *= -1
else:
wynik += znak
switch *= -1
return wynik
def tests(f): def tests(f):
inputs = [['pokemon'], ['do not want'], ['POKEMON']] inputs = [['pokemon'], ['do not want'], ['POKEMON']]

View File

@ -9,12 +9,8 @@ Oba napisy będą składać się wyłacznie z małych liter.
""" """
def common_chars(string1, string2): def common_chars(string1, string2):
wspolne = [] pass
for z in string1.replace(" ", ""):
if z in string2.replace(" ", "") and z not in wspolne:
wspolne.append(z)
return sorted(wspolne)
def tests(f): def tests(f):
inputs = [["this is a string", "ala ma kota"]] inputs = [["this is a string", "ala ma kota"]]

View File

@ -1,31 +0,0 @@
lista = [1, 2, 3]
a=id(lista)
b=id(lista)
if a == b:
print('Lista Immutable')
else:
print('Lista Mutable')
napis = 'Napis'
c=id(napis)
d=id(napis)
if c == d:
print('Napis Immutable')
else:
print('Napis Mutable')
liczba=23.34
e=id(liczba)
f=id(liczba)
if e == f:
print('Liczba Immutable')
else:
print('Liczba Mutable')
print('Koniec')

View File

@ -1,14 +0,0 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
def fibonacci(n):
fn = [0, 1,]
for i in range(2, n):
fn.append(fn[i-1] + fn[i-2])
yield fn
a = fibonacci(10)
for i in a:
print(i)

View File

@ -1,26 +0,0 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import glob
path = 'scores'
os.chdir(path)
max_file_name = ''
max_bleu = 0
file_list = glob.glob('model.iter[0-9][0-9][0-9][0-9][0-9].npz.bleu') + glob.glob('model.iter[0-9][0-9][0-9][0-9][0-9][0-9].npz.bleu')
for file in file_list:
with open(file, 'r') as f:
for line in f.readlines():
fc = line.find(',')
feq = line.find('=') + 1
bleu = float(line[feq:fc])
if bleu > max_bleu:
max_bleu = bleu
max_file_name = file
print(os.getcwd() + '\\' + max_file_name)

View File

@ -1,74 +1,3 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
def is_numeric(x):
ile = len(x)
licznik = 0
for i in x:
if isinstance(i, (int, float)):
licznik += 1
if ile == licznik:
return True
else:
return False
def add_coordinates(c1, c2):
new = []
if len(c1) == len(c2):
for i in range(0, len(c1)):
new.append(c1[i]+c2[i])
return new
class DimensionError(Exception):
def __init__(self, text):
self.text = text
def __str__(self):
return self.text
class Point:
def __init__(self, coordinates):
if not is_numeric(coordinates):
raise Exception('Lista zawiera wartosci nieliczbowe')
self.coordinates = coordinates
self.coordinates_to_string = 'Koordynaty punktu: ['
for c in coordinates:
self.coordinates_to_string += str(c) + ', '
self.coordinates_to_string = self.coordinates_to_string[:-2]
self.coordinates_to_string += ']'
def to_string(self):
print(self.coordinates_to_string)
def __str__(self):
return self.coordinates_to_string
def __add__(self, other):
if len(self.coordinates) != len(other.coordinates):
raise DimensionError('Punkty maja rozne wymiary')
return Point(add_coordinates(self.coordinates, other.coordinates))
def __len__(self):
return len(self.coordinates)
a = Point([1, 1, 5])
b = Point([2, 4, 4])
print(a)
b.to_string()
print(len(b))
c = a + b
print(c)

View File

@ -7,7 +7,7 @@ Zwraca liczbę słów, znaków i linii.
""" """
import sys import sys
import argparse
def count_lines(text): def count_lines(text):
""" return number of lines. """ """ return number of lines. """
@ -32,31 +32,8 @@ def wc(text):
def main(): def main():
""" main """ """ main """
print(wc(sys.stdin.read()))
parser = argparse.ArgumentParser()
parser.add_argument("-l", help="-l switch returns number of lines", action='store_true')
parser.add_argument("-w", help="-w switch returns number of words", action='store_true')
parser.add_argument("-c", help="-c switch returns number of characters", action='store_true')
parser.add_argument("filename", help="path to a file to read from", type=argparse.FileType('rt'), nargs='?')
args = parser.parse_args()
if args.filename is None:
readinput = sys.stdin.read()
else:
readinput = args.filename.read()
outputmsg = ""
if args.l:
outputmsg = "Number of typed lines: {}".format(count_lines(readinput))
elif args.w:
outputmsg = "Number of typed words: {}".format(count_words(readinput))
elif args.c:
outputmsg = "Number of typed characters: {}".format(count_chars(readinput))
else:
outputmsg = "Number of typed (lines, words, characters): {}".format(wc(readinput))
print(outputmsg)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,24 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import pandas as pd
import matplotlib.pyplot as plt
def wczytaj_dane(): def wczytaj_dane():
csv_data = pd.read_csv('mieszkania.csv', index_col='Id') pass
return pd.DataFrame(csv_data)
def most_common_room_number(dane): def most_common_room_number(dane):
pass
dane_agg = dane["Rooms"].value_counts()
return dane_agg.index.tolist()[0]
def cheapest_flats(dane, n): def cheapest_flats(dane, n):
dane_cheapest = dane.sort_values(by=["Expected"])[:n] pass
return dane_cheapest
def find_borough(desc): def find_borough(desc):
dzielnice = ['Stare Miasto', dzielnice = ['Stare Miasto',
@ -29,72 +19,36 @@ def find_borough(desc):
'Winogrady', 'Winogrady',
'Miłostowo', 'Miłostowo',
'Dębiec'] 'Dębiec']
first = "" pass
found = False
for dz in dzielnice:
if dz in desc:
first = dz
found = True
break
if not found:
return 'Inne'
else:
return first
def add_borough(dane): def add_borough(dane):
dane['Borough'] = dane['Location'].map(lambda loc: find_borough(loc)) pass
def write_plot(dane, filename): def write_plot(dane, filename):
pass
dane['Borough'].value_counts().plot(kind='bar', figsize = (10, 10))
plt.savefig(filename)
def mean_price(dane, room_number): def mean_price(dane, room_number):
ff = dane[dane['Rooms'] == room_number] pass
return ff['Expected'].mean()
def find_13(dane): def find_13(dane):
pass
ff = dane[dane['Floor'] == 13]
return ff['Borough'].unique()
def find_best_flats(dane): def find_best_flats(dane):
pass
bf = dane[(dane['Rooms'] == 3) & (dane['Floor'] == 1) & (dane['Borough'] == 'Winogrady')]
return bf
def main(): def main():
dane = wczytaj_dane() dane = wczytaj_dane()
add_borough(dane)
print(dane[:5]) print(dane[:5])
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}" print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
.format(most_common_room_number(dane))) .format(most_common_room_number(dane)))
print("{} to najłądniejsza dzielnica w Poznaniu." print("{} to najłądniejsza dzielnica w Poznaniu."
.format(find_borough("Grunwald i Jeżyce"))) .format(find_borough("Grunwald i Jeżyce"))))
print("Średnia cena mieszkania 3-pokojowego, to: {}" print("Średnia cena mieszkania 3-pokojowego, to: {}"
.format(mean_price(dane, 3))) .format(mean_price(dane, 3)))
print("Dzielnice z mieszkaniami na 13 piętrze, to: {}"
.format(find_13(dane)))
ile = 10
print("Najtańsze oferty mieszkań, to: {}"
.format(cheapest_flats(dane, ile)))
write_plot(dane, 'mieszkania_plot.png')
if __name__ == "__main__": if __name__ == "__main__":
main() main()