Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
e0d6872eda | |||
14ba0bb0ea | |||
6bce9cdb6a | |||
6f36635a56 | |||
f499b8eccd | |||
cbb941187a | |||
5a79c51337 | |||
984bf73c46 | |||
b986a45879 | |||
c8afe1950d | |||
31b4bae680 | |||
a7441350a1 | |||
ac794e117c | |||
090a391b68 | |||
e1ae7f9cae | |||
66007e3252 | |||
70554cf013 | |||
b52078b610 | |||
c941f0f6ac | |||
7cc01637fb | |||
c6901ebfc2 | |||
a946cb82da | |||
e1c9346baa | |||
36e78f1dfa | |||
77ffeebaea | |||
384abbe074 | |||
fd2448691d | |||
e604060124 |
@ -1,38 +1,24 @@
|
||||
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11 | labs03 | labs04 | labs06 | Punkty | Ocena |
|
||||
---------|-----------------|-----------------|-----------------|-----------------|-----------------|----------|----------|----------|--------|-------|
|
||||
s45146 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45147 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45148 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45150 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 8 | 16 | 4 |
|
||||
s45151 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 18 | 4.5 |
|
||||
s45152 | 1 | 1 | 1 | 0 | 1 | 0 | 5 | 8 | 17 | 4 |
|
||||
s45153 | 0 | 1 | 1 | 1 | 1 | 4 | 0 | 8 | 16 | 4 |
|
||||
s45155 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | 8 | 19 | 4.5 |
|
||||
s45156 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45157 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
s45158 | 1 | 1 | 0 | 0 | 1 | 4 | 5 | 8 | 19 | 4.5 |
|
||||
s45159 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 8 | 18 | 4.5 |
|
||||
s45160 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
s45161 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45162 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45163 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
s45164 | 1 | 1 | 0 | 1 | 0 | 0 | 5 | 8 | 16 | 4 |
|
||||
s45165 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45166 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45167 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 17 | 4 |
|
||||
s45168 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
|
||||
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
|
||||
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11
|
||||
---------|-----------------|-----------------|-----------------|-----------------|---------------
|
||||
s45168 | 0 | 0 | 0 | 0 | 0
|
||||
s45162 | 1 | 1 | 1 | 1 | 1
|
||||
s45158 | 1 | 1 | 0 | 0 | 1
|
||||
szwedek | 1 | 1 | 1 | 1 | 1
|
||||
s45155 | 1 | 1 | 1 | 1 | 1
|
||||
s45152 | 1 | 1 | 1 | 0 | 1
|
||||
s45148 | 1 | 1 | 1 | 1 | 1
|
||||
s45166 | 1 | 1 | 1 | 1 | 1
|
||||
s45151 | 1 | 1 | 1 | 1 | 1
|
||||
s45146 | 1 | 1 | 1 | 1 | 1
|
||||
s45150 | 1 | 1 | 1 | 1 | 1
|
||||
s45452 | 1 | 1 | 1 | 1 | 1
|
||||
s45165 | 1 | 1 | 1 | 1 | 1
|
||||
s45160 | 1 | 1 | 1 | 1 | 1
|
||||
s45153 | 0 | 0 | 0 | 0 | 0
|
||||
s45156 | 1 | 1 | 1 | 1 | 1
|
||||
s45157 | 0 | 0 | 1 | 1 | 1
|
||||
s45167 | 1 | 1 | 1 | 1 | 1
|
||||
s45147 | 1 | 0 | 0 | 1 | 0
|
||||
s45159 | 0 | 0 | 0 | 0 | 0
|
||||
s45161 | 1 | 1 | 1 | 1 | 1
|
||||
s45164 | 1 | 1 | 0 | 1 | 0
|
||||
|
@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach.
|
||||
"""
|
||||
|
||||
def even_elements(lista):
|
||||
pass
|
||||
return(lista[::2])
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -5,8 +5,11 @@
|
||||
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
|
||||
"""
|
||||
|
||||
def days_in_year(days):
|
||||
pass
|
||||
def days_in_year(years):
|
||||
if (years % 4 == 0 and years % 100 != 0) or years % 400 == 0:
|
||||
return 366
|
||||
else:
|
||||
return 365
|
||||
|
||||
def tests(f):
|
||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||
|
@ -13,7 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
|
||||
|
||||
|
||||
def oov(text, vocab):
|
||||
pass
|
||||
list_of_words = []
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
@ -7,8 +7,14 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
||||
"""
|
||||
|
||||
def sum_from_one_to_n(n):
|
||||
pass
|
||||
suma = 0
|
||||
|
||||
for i in range(n+1):
|
||||
suma = suma + i
|
||||
if n < 1:
|
||||
return 0
|
||||
else:
|
||||
return suma
|
||||
|
||||
def tests(f):
|
||||
inputs = [[999], [-100]]
|
||||
|
@ -8,9 +8,10 @@ dwoma punktami przestrzeni trójwymiarowej. Punkty są dane jako
|
||||
trzyelementowe listy liczb zmiennoprzecinkowych.
|
||||
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):
|
||||
pass
|
||||
|
||||
return sqrt(sum((x - y) ** 2 for x, y in zip(x, y)))
|
||||
|
||||
def tests(f):
|
||||
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):
|
||||
pass
|
||||
napis = 'N'
|
||||
if n < 5:
|
||||
return "It's not a Big 'No!'"
|
||||
else:
|
||||
return napis + n * 'O' + '!'
|
||||
|
||||
def tests(f):
|
||||
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.
|
||||
"""
|
||||
def char_sum(text):
|
||||
pass
|
||||
suma = 0
|
||||
for c in text:
|
||||
suma += ord(c)
|
||||
return suma
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string"], ["this is another string"]]
|
||||
|
@ -7,7 +7,12 @@ przez 3 lub 5 mniejszych niż 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):
|
||||
inputs = [[10], [100], [3845]]
|
||||
|
@ -9,8 +9,16 @@ Np. leet('leet') powinno zwrócić '1337'.
|
||||
|
||||
|
||||
def leet_speak(text):
|
||||
pass
|
||||
slownik = {'e':3, 'l':1, 'o':0, 't':7}
|
||||
dekod = ''
|
||||
|
||||
for znak in text:
|
||||
if znak in slownik:
|
||||
dekod += str(slownik[znak])
|
||||
else:
|
||||
dekod += znak
|
||||
|
||||
return dekod
|
||||
|
||||
def tests(f):
|
||||
inputs = [['leet'], ['do not want']]
|
||||
|
@ -9,8 +9,16 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||
|
||||
|
||||
def pokemon_speak(text):
|
||||
pass
|
||||
|
||||
wynik = ''
|
||||
switch = 1
|
||||
for znak in text:
|
||||
if switch == 1:
|
||||
wynik += znak.upper()
|
||||
switch *= -1
|
||||
else:
|
||||
wynik += znak
|
||||
switch *= -1
|
||||
return wynik
|
||||
|
||||
def tests(f):
|
||||
inputs = [['pokemon'], ['do not want'], ['POKEMON']]
|
||||
|
@ -9,8 +9,12 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
||||
"""
|
||||
|
||||
def common_chars(string1, string2):
|
||||
pass
|
||||
wspolne = []
|
||||
|
||||
for z in string1.replace(" ", ""):
|
||||
if z in string2.replace(" ", "") and z not in wspolne:
|
||||
wspolne.append(z)
|
||||
return sorted(wspolne)
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string", "ala ma kota"]]
|
||||
|
31
labs03/task01.py
Normal file
31
labs03/task01.py
Normal file
@ -0,0 +1,31 @@
|
||||
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')
|
14
labs03/task02.py
Normal file
14
labs03/task02.py
Normal file
@ -0,0 +1,14 @@
|
||||
#!/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)
|
26
labs03/task05.py
Normal file
26
labs03/task05.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/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)
|
@ -1,3 +1,74 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- 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)
|
||||
|
||||
|
@ -7,7 +7,7 @@ Zwraca liczbę słów, znaków i linii.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
import argparse
|
||||
|
||||
def count_lines(text):
|
||||
""" return number of lines. """
|
||||
@ -32,8 +32,31 @@ def wc(text):
|
||||
|
||||
def 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__":
|
||||
main()
|
||||
|
@ -1,14 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def wczytaj_dane():
|
||||
pass
|
||||
csv_data = pd.read_csv('mieszkania.csv', index_col='Id')
|
||||
return pd.DataFrame(csv_data)
|
||||
|
||||
|
||||
def most_common_room_number(dane):
|
||||
pass
|
||||
|
||||
dane_agg = dane["Rooms"].value_counts()
|
||||
return dane_agg.index.tolist()[0]
|
||||
|
||||
|
||||
def cheapest_flats(dane, n):
|
||||
pass
|
||||
dane_cheapest = dane.sort_values(by=["Expected"])[:n]
|
||||
return dane_cheapest
|
||||
|
||||
|
||||
def find_borough(desc):
|
||||
dzielnice = ['Stare Miasto',
|
||||
@ -19,36 +29,72 @@ def find_borough(desc):
|
||||
'Winogrady',
|
||||
'Miłostowo',
|
||||
'Dębiec']
|
||||
pass
|
||||
first = ""
|
||||
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):
|
||||
pass
|
||||
dane['Borough'] = dane['Location'].map(lambda loc: find_borough(loc))
|
||||
|
||||
|
||||
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):
|
||||
pass
|
||||
ff = dane[dane['Rooms'] == room_number]
|
||||
return ff['Expected'].mean()
|
||||
|
||||
|
||||
def find_13(dane):
|
||||
pass
|
||||
|
||||
ff = dane[dane['Floor'] == 13]
|
||||
return ff['Borough'].unique()
|
||||
|
||||
|
||||
def find_best_flats(dane):
|
||||
pass
|
||||
|
||||
bf = dane[(dane['Rooms'] == 3) & (dane['Floor'] == 1) & (dane['Borough'] == 'Winogrady')]
|
||||
return bf
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
dane = wczytaj_dane()
|
||||
add_borough(dane)
|
||||
print(dane[:5])
|
||||
|
||||
|
||||
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
|
||||
.format(most_common_room_number(dane)))
|
||||
|
||||
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: {}"
|
||||
.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__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user