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
15 changed files with 70 additions and 240 deletions

View File

@ -1,24 +1,38 @@
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
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

View File

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

View File

@ -11,15 +11,9 @@ litery. (OOV = out of vocabulary) (W pythonie istnieje struktura danych tak
jak 'set', która przechowuje elementy bez powtórzeń.)
"""
def oov(text,vocab):
# 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
def oov(text, vocab):
pass

View File

@ -4,15 +4,11 @@
"""
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):
if n <= 1:
return n
else:
return n + sum_from_one_to_n(n - 1)
pass
def tests(f):
inputs = [[999], [-100]]

View File

@ -1,6 +1,7 @@
#!/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
@ -8,11 +9,8 @@ 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):
return (sqrt((x[0]-y[0])**2 + (x[1] - y[1])**2))
pass
def tests(f):
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]

View File

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

View File

@ -6,9 +6,7 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
sumę kodów ASCII znaków.
"""
def char_sum(text):
list_string = [ord(i) for i in text]
suma = sum(list_string)
return(suma)
pass
def tests(f):
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):
sum = 0
for i in range(n):
if (i % 3 == 0) or (i % 5 == 0):
sum += i
return sum
pass
def tests(f):
inputs = [[10], [100], [3845]]

View File

@ -9,11 +9,8 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text):
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)
pass
def tests(f):
inputs = [['leet'], ['do not want']]

View File

@ -7,12 +7,9 @@ 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):
text = list(text)
for i, ele in enumerate(text):
if i % 2 == 0:
text[i] = ele.upper()
return ("".join(text))
pass
def tests(f):

View File

@ -9,18 +9,7 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
def common_chars(string1, string2):
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)
pass
def tests(f):

View File

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