forked from tdwojak/Python2018
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
a9867f7588 | |||
3cad5c014a | |||
57058a0112 | |||
4628385887 | |||
b7c0ed29b4 | |||
884d9ab808 | |||
09af71f29d | |||
2cadffe872 |
@ -6,7 +6,7 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
|||||||
sumę kodów ASCII znaków.
|
sumę kodów ASCII znaków.
|
||||||
"""
|
"""
|
||||||
def char_sum(text):
|
def char_sum(text):
|
||||||
return sum(ord(i) for i in text)
|
pass
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [["this is a string"], ["this is another string"]]
|
inputs = [["this is a string"], ["this is another string"]]
|
||||||
|
@ -7,11 +7,7 @@ przez 3 lub 5 mniejszych niż n.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def sum_div35(n):
|
def sum_div35(n):
|
||||||
sum=0
|
pass
|
||||||
for i in range(n):
|
|
||||||
if (i%3 ==0 or i%5 ==0):
|
|
||||||
sum += i
|
|
||||||
return(sum)
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [[10], [100], [3845]]
|
inputs = [[10], [100], [3845]]
|
||||||
|
@ -9,11 +9,7 @@ Np. leet('leet') powinno zwrócić '1337'.
|
|||||||
|
|
||||||
|
|
||||||
def leet_speak(text):
|
def leet_speak(text):
|
||||||
text = text.replace('e', '3')
|
pass
|
||||||
text = text.replace('l', '1')
|
|
||||||
text = text.replace('o', '0')
|
|
||||||
text = text.replace('t', '7')
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,17 +9,7 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
|||||||
|
|
||||||
|
|
||||||
def pokemon_speak(text):
|
def pokemon_speak(text):
|
||||||
slowo = list(text)
|
pass
|
||||||
wynik = []
|
|
||||||
for i in range(len(slowo)):
|
|
||||||
if i == 0 or i % 2 == 0:
|
|
||||||
wynik.append(slowo[i].upper())
|
|
||||||
|
|
||||||
else:
|
|
||||||
wynik.append(slowo[i])
|
|
||||||
|
|
||||||
slowo = "".join(wynik)
|
|
||||||
return slowo
|
|
||||||
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
|
@ -9,15 +9,8 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def common_chars(string1, string2):
|
def common_chars(string1, string2):
|
||||||
string1 = set(string1.replace(" ", ""))
|
pass
|
||||||
string2 = set(string2.replace(" ", ""))
|
|
||||||
string12 = []
|
|
||||||
for a1 in string1:
|
|
||||||
for a2 in string2:
|
|
||||||
if a1 == a2:
|
|
||||||
string12.append(a1)
|
|
||||||
string12.sort()
|
|
||||||
return string12
|
|
||||||
|
|
||||||
def tests(f):
|
def tests(f):
|
||||||
inputs = [["this is a string", "ala ma kota"]]
|
inputs = [["this is a string", "ala ma kota"]]
|
||||||
|
111070
labs06/311.csv
Normal file
111070
labs06/311.csv
Normal file
File diff suppressed because it is too large
Load Diff
0
labs06/task02.py
Normal file → Executable file
0
labs06/task02.py
Normal file → Executable file
0
labs06/tasks.py
Normal file → Executable file
0
labs06/tasks.py
Normal file → Executable file
@ -1,73 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
from statistics import mode
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
def wczytaj_dane():
|
|
||||||
data = pd.read_csv('mieszkania.csv')
|
|
||||||
return data
|
|
||||||
|
|
||||||
def most_common_room_number(dane):
|
|
||||||
return mode(dane.Rooms)
|
|
||||||
|
|
||||||
|
|
||||||
def cheapest_flats(dane, n):
|
|
||||||
sorted = dane.Expected.sort()
|
|
||||||
return sorted.head(n)
|
|
||||||
|
|
||||||
def find_borough(desc):
|
|
||||||
dzielnice = ['Stare Miasto',
|
|
||||||
'Wilda',
|
|
||||||
'Jeżyce',
|
|
||||||
'Rataje',
|
|
||||||
'Piątkowo',
|
|
||||||
'Winogrady',
|
|
||||||
'Miłostowo',
|
|
||||||
'Dębiec']
|
|
||||||
for dzielnica in dzielnice:
|
|
||||||
list = desc.split(' ')
|
|
||||||
for element in list:
|
|
||||||
if len(element) > 2 and element == dzielnica:
|
|
||||||
return dzielnica
|
|
||||||
break
|
|
||||||
return "Inne"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_borough(dane):
|
|
||||||
dane['Borough'] = dane['Location'].apply(find_borough)
|
|
||||||
return dane
|
|
||||||
|
|
||||||
def write_plot(dane, filename):
|
|
||||||
plotdata = pd.Series(dane.Location.value_counts())
|
|
||||||
plotdata.plot(x='Location', y='Liczba ogłoszeń', kind='bar')
|
|
||||||
plt.savefig(filename)
|
|
||||||
|
|
||||||
|
|
||||||
def mean_price(dane, room_number):
|
|
||||||
mean_price = dane.Expected[(dane['Rooms'] == room_number)]
|
|
||||||
return mean_price.mean()
|
|
||||||
|
|
||||||
def find_13(dane):
|
|
||||||
return dane.Location[(dane['Floor'] == 13)].unique()
|
|
||||||
|
|
||||||
def find_best_flats(dane):
|
|
||||||
return dane[(dane['Location'] == 'Winogrady') & (dane['Rooms'] == 3) & (dane['Floor'] == 1)]
|
|
||||||
|
|
||||||
def main():
|
|
||||||
dane = wczytaj_dane()
|
|
||||||
print(dane[:5])
|
|
||||||
|
|
||||||
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
|
|
||||||
.format(most_common_room_number(dane)))
|
|
||||||
|
|
||||||
print("{} to najladniejsza dzielnica w Poznaniu."
|
|
||||||
.format(find_borough("Grunwald i Jeżyce")))
|
|
||||||
|
|
||||||
print("Srednia cena mieszkania 3-pokojowego, to: {}"
|
|
||||||
.format(mean_price(dane, 3)))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
Loading…
Reference in New Issue
Block a user