Compare commits

...

29 Commits

Author SHA1 Message Date
e69a13c79a labs04 z1 2018-01-06 00:11:57 +01:00
ad880b3674 labs04 z1 2017-12-16 13:29:56 +01:00
d747ed73a8 labs04 z1 2017-12-16 12:24:57 +01:00
46b98e20b7 labs04 z1 2017-12-16 12:24:27 +01:00
7d1a9113f2 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-16 09:07:36 +01:00
293c616c4a labs04 z1 2017-12-16 09:01:07 +01:00
0884ab90a3 labs04 z1 2017-12-16 00:19:41 +01:00
03bcc26529 labs04 z1 2017-12-16 00:02:00 +01:00
d267afe390 labs04 z1 2017-12-03 15:40:52 +01:00
b5a3890c93 labs04 z1 2017-12-03 15:18:22 +01:00
7a1a975bdc Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-03 13:34:21 +01:00
a543262f1a Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-02 15:06:13 +01:00
0a0b8f8a9d z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11 2017-11-29 00:58:00 +01:00
023a824152 z1, z2, z3, z4, z5, z6, z7, z8, z9, z10 2017-11-29 00:37:15 +01:00
f29a32cacd z1, z2, z3, z4, z5, z6, z7, z8, z9, z10 2017-11-29 00:37:01 +01:00
181d55ab25 z1, z2, z3, z4, z5, z6, z7, z8, z9 2017-11-28 22:15:09 +01:00
e6e3ee8e35 z1, z2, z3, z4, z5, z6, z7, z8 2017-11-28 22:08:42 +01:00
fb735b9d88 z1, z2, z3, z4, z5, z6, z7 2017-11-28 22:02:45 +01:00
2956c1c3e0 z1, z2, z3, z4, z5, z6 2017-11-28 22:00:15 +01:00
db719c47a2 z1, z2, z3, z4, z5, z6 2017-11-28 21:59:37 +01:00
b67a851e9d z1, z2, z3, z4, z5 2017-11-28 21:37:54 +01:00
72eb9d01e2 z1, z2, z3 2017-11-28 20:51:36 +01:00
740202ea3f z1, z2, z3 2017-11-28 20:31:33 +01:00
7c35d1ea07 z1, z3 2017-11-19 15:44:10 +01:00
ef738800ee z1, z3 2017-11-19 15:43:24 +01:00
a4151ff0a0 z1, z3 2017-11-19 15:42:50 +01:00
b932a8291e z1, z3 2017-11-19 15:30:55 +01:00
3bb477ce31 z1 2017-11-19 15:00:36 +01:00
13cc2efaea z1 2017-11-19 14:58:57 +01:00
25 changed files with 253 additions and 33 deletions

View File

@ -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):

View File

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

View File

@ -13,8 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
def oov(text, vocab):
pass
VerifiedList = []
TextList = text.split(' ')
for TextListElement in TextList:
if TextListElement not in vocab:
VerifiedList.append(TextListElement)
return VerifiedList
def tests(f):

View File

@ -7,8 +7,16 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
"""
def sum_from_one_to_n(n):
pass
ResultList = []
if n <1:
#ResultList.append(0)
SumResult = 0
else:
SumResult = 0
for i in range(n+1):
SumResult = SumResult + i
#ResultList.append(SumResult)
return SumResult
def tests(f):
inputs = [[999], [-100]]

View File

@ -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):
pass
l = [x,y]
edl = []
for c1 in range(3):
edl.append(l[0][c1] - l[1][c1])
edl2 = [i**2 for i in edl]
return ( sum(edl2) ) ** 0.5
def tests(f):
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]

View File

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

View File

@ -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
res = 0
for i in text:
res += ord(i)
return res
def tests(f):
inputs = [["this is a string"], ["this is another string"]]

View File

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

View File

@ -9,7 +9,12 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text):
pass
text1=text
text1=text1.replace("e","3")
text1=text1.replace("l","1")
text1=text1.replace("o","0")
text1=text1.replace("t","7")
return text1
def tests(f):

View File

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

View File

@ -9,7 +9,18 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
def common_chars(string1, string2):
pass
sl = []
for i in string1:
for j in string2:
if i==j:
sl.append(i)
sly = [x for x in sl if x != ' ']
sly.sort()
slz = []
for z in sly:
if z not in slz:
slz.append(z)
return slz
def tests(f):

0
labs03/task0.py Normal file
View File

6
labs03/task01.py Normal file
View File

@ -0,0 +1,6 @@
a =[1,2,3,4,5]
b='asdf'
c=0.5
print(id(a))
print(id(b))
print(id(c))

10
labs03/task02.py Normal file
View File

@ -0,0 +1,10 @@
def fib(n):
l = [0, 1,]
for i in range(2, n):
l.append(l[i-1] + l[i-2])
yield l
x = fib(7)
for i in x:
print(i)

4
labs03/task03.py Normal file
View File

@ -0,0 +1,4 @@
import requests
r = requests.get('https://api.fixer.io/latest')
j=r.json()
print(j['rates']['PLN'])

29
labs03/task04.py Normal file
View File

@ -0,0 +1,29 @@
from weather import Weather
import datetime as d
weather = Weather()
weatherWro = weather.lookup_by_location("Wroclaw")
print(weatherWro.condition().text())
def fc_conv (f):
res = round((float(f) - 32) / 1.8, 2)
return res
print(fc_conv(1))
fcst = weatherWro.forecast()
temp=[]
day=[]
for i in fcst:
day.append(i.date())
temp.append(i.low())
dayMin = day[temp.index(min(temp))]
dayMin2 = d.datetime.strptime(dayMin, '%d %b %Y')
dayTxt = (dayMin2.weekday())
daysPl = ["Poniedzialek", "Wtorek", "Sroda", "Czwartek", "Piatek", "Sobota", "Niedziela"]
#print(dayMin)
print(daysPl[dayTxt])
print(fc_conv(min(temp)))

20
labs03/task05.py Normal file
View File

@ -0,0 +1,20 @@
from glob import glob as g
i = 0
for file in g('scores/model.iter*.npz.bleu'):
with open(file, 'r') as of:
fl = of.readline()
cB = float(fl[fl.find("=") + 1:fl.find(",")])
if i == 0:
maxB = cB
maxBF =file
else:
if cB > maxB:
maxB = cB
maxBF = file
i += 1
of.close()
print(maxBF)

View File

@ -1,3 +1,12 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#e
def is_numeric(InputList):
OutputLits = []
for i in range(len(InputList)):
t = InputList[i]
OutputLits.append(isinstance(t,(int, float)))
#print(isinstance(x,(int, float)))
return OutputLits
print(is_numeric([-1,2.4,6]))

View File

@ -1,3 +1,28 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
class Employee:
_id = 0
def __init__(self, name, surname):
Employee._id += 1
self.id = Employee._id
self.name = name
self.surname = surname
def get_id(self):
return self.id
class Recruiter(Employee):
recruited = []
def recruit(self, Employee):
emp_id = Employee.id
self.recruited.append(emp_id)
class Programmer(Employee):
def __init__(self, name, surname, Recruiter):
super().__init__(name, surname)
self.recruiter = Recruiter.id

View File

@ -1,3 +1,37 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
def is_numeric(InputList):
OutputLits = []
for i in range(len(InputList)):
t = InputList[i]
OutputLits.append(isinstance(t,(int, float)))
#print(isinstance(x,(int, float)))
return OutputLits
class Point:
def __add__(self, other):
if len(self.cor)!=len(other.cor):
raise DimensionError("DimesnsionError")
else:
return [i+j for (i,j) in zip(self.cor,other.cor)]
def __init__(self, cor):
if (is_numeric(cor)):
self.cor=cor
else:
raise Exception("Wrong input")
def __len__(self):
return len(self.cor)
def __str__(self):
return(str(self.cor))
def __to_string__(self):
return(str(self.cor))
class DimensionError(Exception):
def __init__(self, text):
self.text = text
def __str__(self):
return self.text
test=Point([2,5])
print(str(test))
print(len(test))

View File

@ -5,9 +5,11 @@ import lib
import tools.fib
import sys
import sys
sys.path.append("..")
# sys.path.append("/ssdfa/fsdsfd/sfd/")
# sys.path.append("..")
# import labs02.task01
import labs02.task01
def main():
print("Hello World")

View File

@ -2,10 +2,10 @@
# -*- coding: utf-8 -*-
def suma(liczby):
pass
return sum(liczby)
def main():
print(summa([1, 2, 3, 4]))
print(suma([1, 2, 3, 4]))
if __name__ == "__main__":
main()

View File

@ -0,0 +1,4 @@
import task00 as t
import sys
print(t.suma([3.2,4.5]))
print(sys.argv)

1
labs06/task00.py Normal file
View File

@ -0,0 +1 @@
import pandas as pd

View File

@ -1,14 +1,27 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
import sys
import numpy as np
def wczytaj_dane():
pass
my_data = pd.read_csv('mieszkania.csv',
encoding='utf-8',
index_col='Id',
sep = ',')
return my_data
#print(my_data)
def most_common_room_number(dane):
pass
rooms = dane['Rooms']
rooms_max = rooms.value_counts().index[0]
return rooms_max
#return ( room_num_list[room_num_list.index(max(room_num_list))] )
#pass
def cheapest_flats(dane, n):
pass
expected = dane['Expected']
n_cheapest = expected.sort_values().head(n)
return n_cheapest
def find_borough(desc):
dzielnice = ['Stare Miasto',
@ -19,23 +32,27 @@ def find_borough(desc):
'Winogrady',
'Miłostowo',
'Dębiec']
pass
for dzielnica in dzielnice:
if dzielnica in desc:
return dzielnica
return 'Inne'
def add_borough(dane):
pass
dane['Borough'] = dane.apply(lambda row: find_borough(row['Location']))
def write_plot(dane, filename):
pass
dane['Borough'].value_counts().plot.bar().get_figure().savefig(filename)
def mean_price(dane, room_number):
pass
mean_value = dane.loc[dane['Rooms'] == room_number]['Expected'].mean()
return mean_value
def find_13(dane):
pass
return dane.loc[dane['Floor'] == 13]['Borough'].unique()
def find_best_flats(dane):
pass
best_flats = dane.loc[(df['Borough'] == 'Winogrady') & (dane['Rooms'] == 3) & (dane['Floor'] == 1)]
return best_flats
def main():
dane = wczytaj_dane()
@ -45,7 +62,7 @@ def main():
.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)))