Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
e69a13c79a | |||
ad880b3674 | |||
d747ed73a8 | |||
46b98e20b7 | |||
7d1a9113f2 | |||
293c616c4a | |||
0884ab90a3 | |||
03bcc26529 | |||
d267afe390 | |||
b5a3890c93 | |||
7a1a975bdc | |||
a543262f1a | |||
0a0b8f8a9d | |||
023a824152 | |||
f29a32cacd | |||
181d55ab25 | |||
e6e3ee8e35 | |||
fb735b9d88 | |||
2956c1c3e0 | |||
db719c47a2 | |||
b67a851e9d | |||
72eb9d01e2 | |||
740202ea3f | |||
7c35d1ea07 | |||
ef738800ee | |||
a4151ff0a0 | |||
b932a8291e | |||
3bb477ce31 | |||
13cc2efaea |
@ -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,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]
|
||||
|
@ -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):
|
||||
|
@ -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]]
|
||||
|
@ -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)]]
|
||||
|
@ -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]]
|
||||
|
@ -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"]]
|
||||
|
@ -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]]
|
||||
|
@ -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):
|
||||
|
@ -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']]
|
||||
@ -23,4 +30,4 @@ def tests(f):
|
||||
return "TESTS PASSED"
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(tests(pokemon_speak))
|
||||
print(tests(pokemon_speak))
|
@ -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
0
labs03/task0.py
Normal file
6
labs03/task01.py
Normal file
6
labs03/task01.py
Normal 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
10
labs03/task02.py
Normal 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
4
labs03/task03.py
Normal 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
29
labs03/task04.py
Normal 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
20
labs03/task05.py
Normal 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)
|
@ -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]))
|
@ -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
|
@ -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))
|
||||
|
@ -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")
|
||||
|
@ -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()
|
||||
|
@ -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
1
labs06/task00.py
Normal file
@ -0,0 +1 @@
|
||||
import pandas as pd
|
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user