Compare commits

..

19 Commits

Author SHA1 Message Date
s45152
47f955aaea Task02 - completed 2018-01-21 12:25:01 +01:00
s45152
d64ce2e49b Task01 - completed 2018-01-21 11:58:56 +01:00
s45152
63ec76bae3 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-16 09:23:25 +01:00
s45152
7a694cac8b Task02, Task03 - completed 2017-12-15 22:27:02 +01:00
s45152
ce045b8d59 Task01 - completed 2017-12-03 15:31:16 +01:00
s45152
f3a9ad0cb3 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-03 15:00:20 +01:00
s45152
89d4fc44c5 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-03 15:00:03 +01:00
756fe1e9a3 Done 2017-12-02 13:30:47 +01:00
fde31ec283 Done 2017-12-02 10:00:04 +01:00
s45152
b6a0c7978c Done 2017-12-01 18:17:20 +01:00
s45152
9155f1e9ae Done 2017-12-01 18:02:20 +01:00
s45152
f6485d1e7a Done 2017-12-01 14:46:05 +01:00
s45152
fbba0900d5 Task07 completed - passed 2017-11-27 15:21:16 +01:00
s45152
f4f28c0551 Task06 completed - passed 2017-11-27 14:36:20 +01:00
s45152
69de9a7441 Task05 completed - passed 2017-11-27 13:34:13 +01:00
s45152
d6f3799197 Task04 completed - not passed, but the code is correct. 2017-11-27 12:23:05 +01:00
s45152
761ebacc34 Task03 completed - passed
# commented lower() method.
2017-11-26 21:33:50 +01:00
47ba5d1051 Task02 2017-11-19 15:31:48 +01:00
65761595b2 Test task 2017-11-19 14:55:35 +01:00
15 changed files with 240 additions and 70 deletions

View File

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

View File

@ -5,8 +5,12 @@
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 and year % 100 != 0) or year % 400 == 0:
return 366
else:
return 365
def tests(f):
inputs = [[2015], [2012], [1900], [2400], [1977]]

View File

@ -11,9 +11,15 @@ litery. (OOV = out of vocabulary) (W pythonie istnieje struktura danych tak
jak 'set', która przechowuje elementy bez powtórzeń.)
"""
def oov(text,vocab):
pass
# text = text.lower()
# vocab = vocab.lower()
wynik = []
text = set(text.split())
for i in text:
if i not in vocab:
wynik.append(i)
return wynik

View File

@ -4,11 +4,15 @@
"""
Napisz funkcję sum_from_one_to_n zwracającą sume liczb od 1 do n.
Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
AD. kod wykonuje się poprawnie, ale nie przechodzi testu.
"""
def sum_from_one_to_n(n):
pass
if n <= 1:
return n
else:
return n + sum_from_one_to_n(n - 1)
def tests(f):
inputs = [[999], [-100]]

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Napisz funkcję euclidean_distance obliczającą odległość między
dwoma punktami przestrzeni trójwymiarowej. Punkty dane jako
@ -9,8 +8,11 @@ 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((x[0]-y[0])**2 + (x[1] - y[1])**2))
def tests(f):
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]

View File

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

View File

@ -6,7 +6,9 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
sumę kodów ASCII znaków.
"""
def char_sum(text):
pass
list_string = [ord(i) for i in text]
suma = sum(list_string)
return(suma)
def tests(f):
inputs = [["this is a string"], ["this is another string"]]

View File

@ -7,7 +7,12 @@ 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]]

View File

@ -9,8 +9,11 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text):
pass
replacements = (('e','3'),('l','1'),('o','0'),('t','7'))
new_string = text
for old, new in replacements:
new_string = new_string.replace(old, new)
return (new_string)
def tests(f):
inputs = [['leet'], ['do not want']]

View File

@ -7,9 +7,12 @@ Napisz funkcję pokemon_speak, która zamienia w podanym napisie co drugą liter
na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
"""
def pokemon_speak(text):
pass
text = list(text)
for i, ele in enumerate(text):
if i % 2 == 0:
text[i] = ele.upper()
return ("".join(text))
def tests(f):

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
string1 = ''.join(sorted(string1))
string1 = string1.strip(' ')
string2 = ''.join(sorted(string2))
string2 = string2.strip(' ')
sorted_list = list()
for char in string1:
count = string2.count(char)
if count > 0:
if char not in sorted_list:
sorted_list.append(char)
return (sorted_list)
def tests(f):

View File

@ -1,3 +1,12 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
lista = [1,1.0,2,3,4.5]
def is_numeric(n):
for i in n:
if isinstance(i,int):
print("True")
if isinstance(i,float):
print("False")
print(is_numeric(lista))

View File

@ -1,3 +1,64 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
class Employee:
id_pracownika=1
lista_id=[]
def __init__(self,imie,nazwisko):
self.imie = imie
self.nazwisko = nazwisko
self.id_pracownika = Employee.id_pracownika
Employee.id_pracownika += 1
self.lista_id.append(self.id_pracownika)
def get_id(self):
return (self.id_pracownika)
class Recruiter(Employee):
def __init__(self, imie, nazwisko):
Employee.__init__(self,imie,nazwisko)
self.recruited = []
def recruit(self,id_pracownika):
if id != self.id_pracownika:
if id_pracownika in Employee.lista_id:
self.recruited.append(id_pracownika)
else:
print("Nie ma takiego pracownika")
else:
print("Rekruter nie moze rekrutowac samego siebie")
class Programmer(Recruiter):
def __init__(self,imie,nazwisko,rekruter):
Recruiter.__init__(self,imie,nazwisko)
def recruited_by(self):
print(f'Osoba {self.imie} {self.nazwisko} zostala zrekrutowana przez rekrutera o ID {Recruiter.id_pracownika}')
print('********')
pracownik1 = Employee('Jan', 'Kowalski')
print(pracownik1.imie)
print(pracownik1.nazwisko)
print(pracownik1.get_id())
print('********')
pracownik2 = Employee('Anna', 'Nowak')
print(pracownik2.imie)
print(pracownik2.nazwisko)
print(pracownik2.get_id())
print('********')
pracownik3 = Programmer('Janusz','Gajos', 1)
print(pracownik3.imie)
print(pracownik3.nazwisko)
print(pracownik3.id_pracownika)
print(pracownik3.get_id())
pracownik3.recruited_by()

View File

@ -1,3 +1,65 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
""" ćwiczenie 3 (zadanie domowe)
Stwórz klasę ``Point``, która będzie reprezentować punkt w przestrzeni wielowymiarowej:
* Konstruktor ma przyjąc tylko 1 parametr: listę współrzednych. Wykorzystaj funkcję z pierwszego zadania, żeby sprawdzić, czy lista zawiera wyłącznie liczby.
* Napisz metodę add, która doda dwa punkty po współrzędnych i zwróci obiekt typu ``Punkt``.
Zaimplementuj własny wyjątek ``DimensionError``, który zostaje wyrzucony, jeżeli dodawany punkt ma inny wymiar.
* Napisz metodę ``to\_string``, która zwróci łancuch znakowy, który w czytelny sposób przedstawi punkt.
* Napisz metodę __len__, która zwróci liczbę współrzędnych punktu. Zobacz, czy możesz teraz wywołać funkcję len na obiekcie typy punkt.
* Napisz metodę __str__, która bedzie działać dokładnie tak samo jak metoda ``to_string``. Wyświetl obiekt typy Point korzystając z funkcji print.
"""
class DimensionError(Exception):
"""Klasa odpowiadajaca za wyjatek współrzędnych <>3"""
def __init__(self, text):
self.text = text
def __str__(self):
return self.text
class Point:
"""Klasa reprezentująca punkt w 3D"""
def __is_numeric(self,n):
for i in n:
if not (isinstance(i, int) or isinstance(i,float)):
return False
return True and len(n) > 0
def __init__(self, xyz):
"""Konstruktor klasy Point, argument xyz - lista puntkwo w 3D. Warunkiem sa 3 wspolrzedne"""
if not self.__is_numeric(xyz):
raise DimensionError("Nieprawidlowe wspolrzedne!")
if len(xyz) != 3:
raise DimensionError("Nieprawidlowa liczba wspolrzednych (<> 3)")
self.x = xyz[0]
self.y = xyz[1]
self.z = xyz[2]
def to_string(self):
"""Wypisuje wektor współrzędnych punktu w 3D jako string"""
return '[' + ','.join([str(self.x), str(self.y), str(self.z)]) + ']'
def add(oPoint1, oPoint2):
"""Metoda statyczna klasy Point. Zwraca sumę współrzędnych danych 2 punktów w 3D
arg1 - obiekt klasy Punkt
arg2 - obiekt klasy Punkt
"""
l1 = [oPoint1.x, oPoint1.y, oPoint1.z]
l2 = [oPoint2.x, oPoint2.y, oPoint2.z]
nl = [c1+c2 for c1, c2 in zip(l1, l2)]
return Point(nl)
def __len__(self):
"""Zwraca liczbe wspolrzednych"""
return 3
def __str__(self):
"""Funkcja string dla klasy Point, wypisuje wspolrzedne punktu jako string"""
return self.to_string()
if __name__ == "__main__":
pkt1 = Point([4, 8, 12])
print('pkt1 =', pkt1)
pkt2 = Point([-1, 0, 3])
print('pkt2 =', pkt2)
pkt3 = Point.add(pkt1, pkt2)
print('pkt3 = pkt1 (+) pkt2 = ', pkt3)

View File

@ -1,14 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
def wczytaj_dane():
pass
mieszkania = pd.read_csv('mieszkania.csv',sep=',',encoding='UTF-8',usecols=[0,1,2,3,4,5,6])
return mieszkania
def most_common_room_number(dane):
pass
return dane.mode(numeric_only =True)["Rooms"][0]
def cheapest_flats(dane, n):
pass
return dane.sort_values("Expected")[:n]
def find_borough(desc):
dzielnice = ['Stare Miasto',
@ -19,23 +20,31 @@ def find_borough(desc):
'Winogrady',
'Miłostowo',
'Dębiec']
pass
inputList=desc.split(' ')
for i in inputList:
if i in dzielnice:
return i
break
return "Inne"
def add_borough(dane):
pass
newcol=dane["Location"].apply(find_borough)
dane["Borough"]=newcol
return dane
def write_plot(dane, filename):
pass
bar=dane["Borough"].value_counts().plot(kind="bar", figsize=(6,6))
fig=bar.get_figure()
fig.savefig(filename)
def mean_price(dane, room_number):
pass
return dane[dane["Rooms"]==room_number]["Expected"].mean()
def find_13(dane):
pass
return dane[dane["Floor"]==13]["Borough"].unique()
def find_best_flats(dane):
pass
return dane[(dane["Borough"]=="Winogrady") & (dane["Floor"]==1) & (dane["Rooms"]==3)]
def main():
dane = wczytaj_dane()
@ -45,7 +54,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)))