diff --git a/02ex01.py b/02ex01.py
new file mode 100644
index 0000000..18ec336
--- /dev/null
+++ b/02ex01.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3
+
+"""Calculate deposit percent yield based on time period.
+
+Imagine your friend wants to put money on a deposit.
+He has got many offers from different banks:
+- First bank declares +A% each day;
+- Second bank promises +B% each month;
+- Third bank offers +C% by the end of the year;
+- The 4th bank promotes +D% in a 10-year term;
+- ... and so on ...
+
+Your friend gets a terrible headache calculating all this stuff,
+and asks you to help checking everything. You quickly realize
+it is a common task and having a simple script is a great idea.
+
+Let's implement this.
+
+A simplified task:
+Given the SUM amount of money, and PERCENT yield promised in a
+FIXED_PERIOD of time, calculate the TOTAL equivalent of money
+in a SET_PERIOD of time.
+
+Math formula:
+p = PERCENT / 100
+TOTAL = SUM * ((1 + p) ** (SET_PERIOD / FIXED_PERIOD))
+"""
+
+
+# TODO: add lines to calculate yields for some common periods
+# of time (e.g. 1 month, 1 year, 5 years, 10 years)
+# TODO: change the script to output the 1-year percent yield
+# as well
+# TODO: (extra) Output only percents if the initial SUM is
+# not known at the moment the script is run
+
+
+USAGE = """USAGE: {script} initial_sum percent fixed_period set_period
+
+\tCalculate deposit yield. See script source for more details.
+"""
+USAGE = USAGE.strip()
+
+
+def deposit(initial_sum, percent, fixed_period, set_period):
+ """Calculate deposit yield."""
+ per = percent / 100
+ growth = (1 + per) ** (set_period / fixed_period)
+ return initial_sum * growth
+
+
+def main(args):
+ """Gets called when run as a script."""
+ if len(args) != 4 + 1:
+ exit(USAGE.format(script=args[0]))
+
+ args = args[1:]
+ initial_sum, percent, fixed_period, set_period = map(float, args)
+
+ # same as
+ # initial_sum = float(args[0])
+ # percent = float(args[1])
+ # ...
+
+ res = deposit(initial_sum, percent, fixed_period, set_period)
+ print(res)
+
+
+if __name__ == '__main__':
+ import sys
+
+ main(sys.argv)
+
diff --git a/02ex02.py b/02ex02.py
new file mode 100644
index 0000000..8036fe9
--- /dev/null
+++ b/02ex02.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python3
+
+"""The famous Vikings restoraunt from the Monthy Python sketch.
+
+See the sketch origins video first:
+https://www.youtube.com/watch?v=zLih-WQwBSc
+"""
+
+import random
+
+DEF_CHOICE = 8 # how many times to repeat a dish
+MENU = ['spam', 'egg', 'sausage', 'bacon'] # that's all combinations
+MENU_MULTI = MENU + ['eggs', 'sausages'] # including plurals
+JOINTS = [', and ', ', ', ' and ', ' with ', ' and double portion of ']
+PREFERED = MENU[0] # that's what promoted most
+FORBIDDEN = {'not', 'without', 'no'}
+
+SONG = ', '.join([PREFERED.capitalize()] + [PREFERED] * DEF_CHOICE) + '!'
+
+D_WELCOME = ('Welcome to the Vikings restaurant.\n'
+ 'What would you like to eat?')
+D_CHOICE = '> '
+D_PROMOTE = "We highly recommend {dishes}" + f', and {PREFERED}...'
+D_GOOD = "That's a perfect choice. Let's have more {dishes}" + f', and {PREFERED}!'
+D_BAD = "Disgusting. Who eats {dishes}?"
+D_UNAVAILABLE = "That's not on our menu.\nWe have {dishes}."
+
+
+def dialog(num_choice=DEF_CHOICE):
+ """User dialog logic."""
+ print(D_WELCOME)
+
+ entry = input(D_CHOICE).strip() # user entry
+ words = entry.lower().split()
+
+ def promote():
+ print(D_PROMOTE.format(dishes=get_dishes(num_choice)))
+
+ if set(words) & set(MENU_MULTI):
+ # user named something on the menu - do further check
+ if set(words) & set(FORBIDDEN):
+ # user asked not to put common dishes - blame
+ print(D_BAD.format(dishes=entry))
+ promote()
+ else:
+ # user asked for what's on menu - compliment
+ print(D_GOOD.format(dishes=entry))
+ print(f'Vikings: "{SONG}"')
+ return
+
+ if not words:
+ # user haven't selected anything - promote a good menu
+ promote()
+ return
+
+ print(D_UNAVAILABLE.format(dishes=get_dishes(num_choice)))
+ return
+
+
+def get_dishes(number):
+ """Form a random combination of dishes"""
+ sel = list(MENU)
+
+ res = []
+ for i in range(number):
+ rnd = random.choice(sel)
+ #sel.remove(rnd)
+ res.append(rnd)
+ res.append(random.choice(JOINTS))
+ res = res[:-1] # remove last element
+
+ return ''.join(res)
+
+
+TIP = """Next time call "{script} num" to set number of dishes."""
+
+def main(args):
+ script, *args = args
+
+ """Gets called when run as a script."""
+ if len(args) > 1:
+ exit('Too many arguments. ' + TIP.format(script=script))
+
+ num = DEF_CHOICE
+ if len(args) > 0:
+ num = int(args[0])
+
+ dialog(num)
+
+ if len(args) < 1:
+ print('\tTip:', TIP.format(script=script))
+
+
+if __name__ == '__main__':
+ import sys
+
+ main(sys.argv)
diff --git a/AverageValue.py b/AverageValue.py
new file mode 100644
index 0000000..37d8469
--- /dev/null
+++ b/AverageValue.py
@@ -0,0 +1,5 @@
+def avg(*args):
+ return sum(*args) / len(*args)
+
+
+
diff --git a/Cards.py b/Cards.py
new file mode 100644
index 0000000..17c7eaa
--- /dev/null
+++ b/Cards.py
@@ -0,0 +1,50 @@
+import random
+
+
+class Cards:
+ RANKS = list(range(2, 11)) + list('JQKA')
+ SUITS = ['\u2660', '\u2665', '\u2666', '\u2663']
+
+ def __init__(self):
+ self.rank = self.RANKS
+ self.suits = self.SUITS
+
+ def __repr__(self):
+ return f"{self.magic_cards()}"
+
+ @classmethod
+ def create_deck(cls):
+ deck = []
+ deck_list = [(str(i), j) for i in cls.RANKS for j in cls.SUITS]
+ for i in deck_list:
+ deck.append("".join(i))
+ return deck
+
+ @classmethod
+ def generate_card(cls, n=1):
+ cards_list = []
+ for i in range(n):
+ cards_list.append(random.choice(cls.create_deck()))
+ return cards_list
+
+ def magic_cards(self):
+ from datetime import datetime
+ print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n"
+ f"How many cards will you get?\n -->")
+ num_cards = input()
+ try:
+ int(num_cards)
+ if 0 < int(num_cards) < 5:
+ week_days_list = ['monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
+ get_cards = self.generate_card(int(num_cards))
+ num_cards -= 1
+ print(f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n"
+ f"--->>>{week_days_list[datetime.now().weekday()]}<<<---")
+ else:
+ print('too many cards you probably need to see a fortune teller')
+ except ValueError:
+ print("it seems that tomorrow......\n you will learn how letters differ from numbers")
+
+x = Cards()
+print(x.generate_card())
+print(x.magic_cards())
diff --git a/HW Lacture#8/Exceptions.py b/HW Lacture#8/Exceptions.py
new file mode 100644
index 0000000..8fda0eb
--- /dev/null
+++ b/HW Lacture#8/Exceptions.py
@@ -0,0 +1,27 @@
+class Errors(Exception):
+ pass
+
+
+class CityNameError(Errors):
+ error_message = ('City name must contain only letters')
+
+ def __init__(self):
+ super().__init__()
+ self.msg = self.error_message
+
+ def __str__(self):
+ return self.msg
+
+
+class CoordError(Errors):
+ error_message = ("Invalid Coords. Try again")
+
+ def __init__(self):
+ super().__init__()
+ self.msg = self.error_message
+
+ def __str__(self):
+ return self.msg
+
+
+
diff --git a/HW Lacture#8/WeatherClases.py b/HW Lacture#8/WeatherClases.py
new file mode 100644
index 0000000..b63895a
--- /dev/null
+++ b/HW Lacture#8/WeatherClases.py
@@ -0,0 +1,71 @@
+from urllib.request import urlopen
+import json
+from Exeptions import CityNameError, CoordError
+# https://api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key}
+# https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
+TOKEN = '18c6e0f43541c0148fa43fbd483f79b4'
+
+
+class City():
+ def __init__(self, name, latitude=None, longitude=None):
+ self._name = name
+ self._latitude = latitude
+ self._longitude = longitude
+ if self._latitude is None and self._longitude is None:
+ self.set_coords()
+
+ def get_coords(self):
+ if self._name.isalpha():
+ url = f'http://api.openweathermap.org/geo/1.0/direct?q={self._name}&appid={TOKEN}'
+ response = urlopen(url)
+ data = response.read()
+ data = data.decode('utf-8')
+ res = json.loads(data)
+ lat = res[0]['lat']
+ lon = res[0]['lon']
+ else:
+ raise CityNameError
+
+
+ return lat, lon
+
+ def set_coords(self):
+ self._latitude, self._longitude = self.get_coords()
+
+ def __str__(self):
+ return f'City {self._name} has latitude:{self._latitude} ' \
+ f'and longitude{self._longitude}'
+
+
+class Weather():
+
+ def __init__(self, city, coords=None):
+ self.city = city
+ self.coords = coords
+
+ def current_weather(self):
+ if self.coords:
+ try:
+ float(self.coords[0])
+ float(self.coords[1])
+ except ValueError:
+ raise CoordError()
+
+
+ else:
+ self.coords = City(self.city).get_coords()
+
+ url = f'https://api.openweathermap.org/data/2.5/weather?lat={self.coords[0]}&lon={self.coords[1]}&units=metric&appid={TOKEN}'
+ response = urlopen(url).read().decode('utf-8')
+ res = json.loads(response)
+ # print(res)
+ return (f"Температура: {res['main']['temp']} "
+ f"відчувається як: {res['main']['feels_like']} "
+ f"швидкість вітру: {res['wind']['speed']}")
+
+ def __str__(self):
+ return self.current_weather()
+
+
+
+
diff --git a/HW#10 Lecture#13/.idea/.gitignore b/HW#10 Lecture#13/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/HW#10 Lecture#13/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml b/HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml b/HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#10 Lecture#13/.idea/misc.xml b/HW#10 Lecture#13/.idea/misc.xml
new file mode 100644
index 0000000..97b8f8e
--- /dev/null
+++ b/HW#10 Lecture#13/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/HW#10 Lecture#13/.idea/modules.xml b/HW#10 Lecture#13/.idea/modules.xml
new file mode 100644
index 0000000..9bfe4fa
--- /dev/null
+++ b/HW#10 Lecture#13/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#10 Lecture#13/.idea/vcs.xml b/HW#10 Lecture#13/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/HW#10 Lecture#13/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/database/employees.json b/HW#10 Lecture#13/red-Arrow/database/employees.json
new file mode 100644
index 0000000..fb78eb6
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/database/employees.json
@@ -0,0 +1 @@
+[{"first_name": "test", "last_name": "test", "email": "test@test.com", "phone": "+380971750340", "work_id": "1", "type": "plant", "id": 1}, {"first_name": "test", "last_name": "test", "email": "turupru8@gmail.com", "phone": "+380971750340", "work_id": "1", "type": "plant", "id": 2}, {"first_name": "Roman", "last_name": "Rostotskyi", "email": "roman.rostotskyi@vnv.solutions", "phone": "+380685553001", "work_id": 1, "type": "salon", "id": 3}]
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/database/plants.json b/HW#10 Lecture#13/red-Arrow/database/plants.json
new file mode 100644
index 0000000..049ac4a
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/database/plants.json
@@ -0,0 +1 @@
+[{"name": "Azovstal", "address": "Ukraine, Mariupol, st. Address", "id": 1}, {"name": "Silmash", "address": "Ukraine, Ivano-Frankivsk, st. Address 2", "id": 2}]
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/database/sales_departament.json b/HW#10 Lecture#13/red-Arrow/database/sales_departament.json
new file mode 100644
index 0000000..0637a08
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/database/sales_departament.json
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/database/salons.json b/HW#10 Lecture#13/red-Arrow/database/salons.json
new file mode 100644
index 0000000..dd891c7
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/database/salons.json
@@ -0,0 +1 @@
+[{"name": "Ford", "address": "Ukraine, Lviv, Doroshenka st.", "id": 1}, {"name": "Mersedes", "address": "Ukraine, Bakhmut, Geroyiv UPA st.", "id": 2}]
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__init__.py b/HW#10 Lecture#13/red-Arrow/helpers/__init__.py
new file mode 100644
index 0000000..a040fbd
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/helpers/__init__.py
@@ -0,0 +1,2 @@
+from .helpers import *
+from .system_helpers import *
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000..443c4b9
Binary files /dev/null and b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc differ
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc
new file mode 100644
index 0000000..d39cb24
Binary files /dev/null and b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc differ
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/helpers.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/helpers.cpython-310.pyc
new file mode 100644
index 0000000..79412e1
Binary files /dev/null and b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/helpers.cpython-310.pyc differ
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc
new file mode 100644
index 0000000..13ad4db
Binary files /dev/null and b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc differ
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/decorators_helpers.py b/HW#10 Lecture#13/red-Arrow/helpers/decorators_helpers.py
new file mode 100644
index 0000000..7c8acdc
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/helpers/decorators_helpers.py
@@ -0,0 +1,12 @@
+
+def is_email_valid(func):
+ def wrapper(email, y, a, z, b, c):
+ if "@" in email:
+ if "." in email.split("@")[1]:
+ func(email, y, a, z, b, c)
+ else:
+ print("Email invalid without dot!!!!")
+ else:
+ print("Email invalid without @ !!!!")
+ return wrapper
+
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/helpers.py b/HW#10 Lecture#13/red-Arrow/helpers/helpers.py
new file mode 100644
index 0000000..33f1f2f
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/helpers/helpers.py
@@ -0,0 +1,110 @@
+from .system_helpers import save_to_file, get_file_data, save_list_to_file
+from .decorators_helpers import is_email_valid
+
+
+@is_email_valid
+def save(
+ email, first_name, last_name,
+ phone, work_id, type):
+ new_employee = {
+ "first_name": first_name,
+ "last_name": last_name,
+ "email": email,
+ "phone": phone,
+ "work_id": work_id,
+ "type": type,
+ }
+ save_to_file(new_employee, "database/employees.json")
+
+
+def update(id):
+ employers = get_file_data("database/employees.json")
+ for employee in employers:
+ if id == employee["id"]:
+ employee["email"] = input("Email: ")
+ employee["first_name"] = input("First name: ")
+ employee["last_name"] = input("Last Name: ")
+ employee["phone"] = input("Phone: ")
+ employee["work_id"] = input("Work id: ")
+ employee["type"] = input("type: ")
+
+ save_list_to_file(employers, "database/employees.json")
+
+
+def get_all_employers():
+ employees = get_file_data("database/employees.json")
+ for employee in employees:
+ print(employee["email"])
+ print(employee["first_name"])
+ print(employee["last_name"])
+ print(employee["phone"])
+ print(employee["work_id"])
+ print(employee["type"])
+
+
+def get_employee_by_email(email):
+ employees = get_file_data("database/employees.json")
+ for employee in employees:
+ if employee["email"] == email:
+ print(employee["email"])
+ print(employee["first_name"])
+ print(employee["last_name"])
+ print(employee["phone"])
+ print(employee["work_id"])
+ print(employee["type"])
+ return employee
+
+
+def save_plant(name, address):
+ new_plant = {"name": name, "address": address}
+ save_to_file(new_plant, "database/plants.json")
+
+
+def get_all_plants():
+ plants = get_file_data("database/plants.json")
+ for plant in plants:
+ print(plant["name"])
+ print(plant["address"])
+
+
+def get_plant_by_id(id):
+ plants = get_file_data("database/plants.json")
+ for plant in plants:
+ if plant["id"] == id:
+ print(plant["name"])
+ print(plant["address"])
+
+
+def save_salon(name, address):
+ new_el = {"name": name, "address": address}
+ save_to_file(new_el, "database/salons.json")
+
+
+def get_salon_by_id(id):
+ salons = get_file_data("database/salons.json")
+ for salon in salons:
+ if salon["id"] == id:
+ print(salon["name"])
+ print(salon["address"])
+
+
+def save_sales_departament(name, address):
+ new_s_d = {"name": name, "address": address}
+ save_to_file(new_s_d, "database/sales_departament.json")
+
+
+def get_sales_departament_by_id(id):
+ sales_departament = get_file_data("database/sales_departament.json")
+ for s_d in sales_departament:
+ if s_d["id"] == id:
+ print(s_d["name"])
+ print(s_d["address"])
+
+
+def delete_employee(id):
+ employees = get_file_data("database/employees.json")
+ for i in range(len(employees)):
+ if id == employees[i]["id"]:
+ del employees[i]
+ break
+ save_list_to_file(employees, "database/employees.json")
\ No newline at end of file
diff --git a/HW#10 Lecture#13/red-Arrow/helpers/system_helpers.py b/HW#10 Lecture#13/red-Arrow/helpers/system_helpers.py
new file mode 100644
index 0000000..1ba0ad3
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/helpers/system_helpers.py
@@ -0,0 +1,44 @@
+import json
+
+
+def get_file_data(path):
+ try:
+ file = open(path, "r")
+ try:
+ data_list = json.loads(file.read())
+ return data_list
+ except:
+ print("Error while working with the file")
+ finally:
+ file.close()
+ except FileNotFoundError:
+ print("File not found")
+
+
+def save_list_to_file(data, path):
+ try:
+ file = open(path, "w")
+ try:
+ data_in_json = json.dumps(data)
+ file.write(data_in_json)
+ except :
+ print("Error while working with the file")
+ finally:
+ file.close()
+ except FileNotFoundError:
+ print("File not found")
+
+
+def save_to_file(data: dict, path: str):
+ data_list = get_file_data(path)
+ try:
+ if len(data_list) < 1:
+ data["id"] = 1
+ else:
+ data["id"] = len(data_list) + 1
+ data_list.append(data)
+ save_list_to_file(data_list, path)
+ except TypeError:
+ #цю помилку ловимо у випадку коли файл для запису повністю пустий( не містить навіть пустого списку)
+ print("It seems that a non-json file was used for recording")
+
diff --git a/HW#10 Lecture#13/red-Arrow/main.py b/HW#10 Lecture#13/red-Arrow/main.py
new file mode 100644
index 0000000..3880108
--- /dev/null
+++ b/HW#10 Lecture#13/red-Arrow/main.py
@@ -0,0 +1,65 @@
+from helpers import save, get_all_employers, get_employee_by_email,\
+ update, save_plant, get_all_plants,\
+ get_plant_by_id, save_salon, get_salon_by_id, delete_employee,\
+ get_sales_departament_by_id, save_sales_departament
+
+
+while True:
+ print("1.Add new Employee\n2.Get all Employees\n3.Get employee by email\n4. Update Employee\n"
+ "5. Add plant\n6.Get all plants\n7.Get plant by id\n8.Add salon\n9.Delete employee\n10.Add sales departament")
+ try:
+ flag = int(input("Choose menu item: "))
+ if flag == 1:
+ email = input("Employee email: ")
+ first_name = input("Employee first name: ")
+ last_name = input("Employee last name: ")
+ phone_number = input("Employee phone number: ")
+ work_id = int(input("Employee work id: "))
+ type = input("Employee work type: ")
+ save(email, first_name, last_name, phone_number, work_id, type)
+ elif flag == 2:
+ get_all_employers()
+ elif flag == 3:
+ email_to_find = input("Type email of employee which you want to find: ")
+ employee = get_employee_by_email(email_to_find)
+ print("1.Display info about place of work.\n0.Exit")
+ flag_inner = int(input("Your choose: "))
+ if flag_inner == 1:
+ if employee["type"] == "plant":
+ get_plant_by_id(int(employee["work_id"]))
+ elif employee["type"] == "salon":
+ get_salon_by_id(int(employee["work_id"]))
+ elif employee["type"] == "sales_departament":
+ get_sales_departament_by_id(int(employee["work_id"]))
+
+ else:
+ continue
+ elif flag == 4:
+ id = int(input("Type a id of user which you want to update: "))
+ update(id)
+ elif flag == 5:
+ name = input("Type a name of Plant: ")
+ address = input("Type an address of Plant: ")
+ save_plant(name, address)
+ elif flag == 6:
+ get_all_plants()
+ elif flag == 7:
+ id = int(input("Id of plant: "))
+ get_plant_by_id(id)
+
+ elif flag == 8:
+ name = input("Type a name of Salon: ")
+ address = input("Type an address of Salon: ")
+ save_salon(name, address)
+ elif flag == 9:
+ id = int(input("Id of element which you want to delete: "))
+ delete_employee(id)
+ elif flag == 10:
+ name = input("Type a name of sales departament: ")
+ address = input("Type an address of sales departament: ")
+ save_sales_departament(name, address)
+ except ValueError:
+ print("Wrong input. Please type again")
+
+
+ print("===============================================================================")
diff --git a/HW#11Lecture#14/.idea/.gitignore b/HW#11Lecture#14/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/HW#11Lecture#14/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/HW#11Lecture#14/.idea/HW#11Lecture#14.iml b/HW#11Lecture#14/.idea/HW#11Lecture#14.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/HW#11Lecture#14/.idea/HW#11Lecture#14.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml b/HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#11Lecture#14/.idea/misc.xml b/HW#11Lecture#14/.idea/misc.xml
new file mode 100644
index 0000000..b6e0fde
--- /dev/null
+++ b/HW#11Lecture#14/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/HW#11Lecture#14/.idea/modules.xml b/HW#11Lecture#14/.idea/modules.xml
new file mode 100644
index 0000000..ce30027
--- /dev/null
+++ b/HW#11Lecture#14/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#11Lecture#14/.idea/vcs.xml b/HW#11Lecture#14/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/HW#11Lecture#14/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#11Lecture#14/helpers/__pycache__/github.cpython-310.pyc b/HW#11Lecture#14/helpers/__pycache__/github.cpython-310.pyc
new file mode 100644
index 0000000..dcc1d62
Binary files /dev/null and b/HW#11Lecture#14/helpers/__pycache__/github.cpython-310.pyc differ
diff --git a/HW#11Lecture#14/helpers/__pycache__/writter.cpython-310.pyc b/HW#11Lecture#14/helpers/__pycache__/writter.cpython-310.pyc
new file mode 100644
index 0000000..6e14bc1
Binary files /dev/null and b/HW#11Lecture#14/helpers/__pycache__/writter.cpython-310.pyc differ
diff --git a/HW#11Lecture#14/helpers/github.py b/HW#11Lecture#14/helpers/github.py
new file mode 100644
index 0000000..e4b4aa2
--- /dev/null
+++ b/HW#11Lecture#14/helpers/github.py
@@ -0,0 +1,20 @@
+import requests
+import json
+
+def get_github_repositories(query, page):
+ response = requests.get("https://api.github.com/search/repositories?q=" + query + "&page=" + page)
+ return response.content
+
+
+def json_parser(body):
+ data = json.loads(body)
+ repositories = []
+ for el in data["items"]:
+ new_repo = {
+ "name": el["name"],
+ "full_name": el["full_name"],
+ "private": el["private"],
+ "description": el["description"]
+ }
+ repositories.append(new_repo)
+ return repositories
\ No newline at end of file
diff --git a/HW#11Lecture#14/helpers/writter.py b/HW#11Lecture#14/helpers/writter.py
new file mode 100644
index 0000000..d38fd1a
--- /dev/null
+++ b/HW#11Lecture#14/helpers/writter.py
@@ -0,0 +1,10 @@
+import csv
+
+
+def write(data):
+ with open('repositories.csv', "a") as f:
+ writer = csv.writer(f)
+ for el in data:
+ row = list(el.values())
+ writer.writerow(row)
+
diff --git a/HW#11Lecture#14/main.py b/HW#11Lecture#14/main.py
new file mode 100644
index 0000000..e9a10b9
--- /dev/null
+++ b/HW#11Lecture#14/main.py
@@ -0,0 +1,15 @@
+import argparse
+from helpers.github import get_github_repositories, json_parser
+from helpers.writter import write
+
+parser = argparse.ArgumentParser()
+
+parser.add_argument("-q", dest="query")
+parser.add_argument("-p", dest="page")
+
+args = parser.parse_args()
+
+body = get_github_repositories(args.query, args.page)
+repositories = json_parser(body)
+write(repositories)
+print("Done!")
diff --git a/HW#11Lecture#14/repositories.csv b/HW#11Lecture#14/repositories.csv
new file mode 100644
index 0000000..8c20bfe
--- /dev/null
+++ b/HW#11Lecture#14/repositories.csv
@@ -0,0 +1,150 @@
+django,django/django,False,The Web framework for perfectionists with deadlines.
+DjangoBlog,liangliangyy/DjangoBlog,False,🍺基于Django的博客系统
+django-rest-framework,encode/django-rest-framework,False,Web APIs for Django. 🎸
+django-cms,django-cms/django-cms,False,The easy-to-use and developer-friendly enterprise CMS powered by Django
+cookiecutter-django,cookiecutter/cookiecutter-django,False,Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
+django-allauth,pennersr/django-allauth,False,"Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication."
+django-oscar,django-oscar/django-oscar,False,Domain-driven e-commerce for Django
+mezzanine,stephenmcd/mezzanine,False,CMS framework for Django
+django-haystack,django-haystack/django-haystack,False,Modular search for Django
+django-ex,sclorg/django-ex,False,Django Example
+django-extensions,django-extensions/django-extensions,False,This is a repository for collecting global custom management extensions for the Django Framework.
+awesome-django,wsvincent/awesome-django,False,A curated list of awesome things related to Django
+django-tastypie,django-tastypie/django-tastypie,False,Creating delicious APIs for Django apps since 2010.
+django2.0-course,HaddyYang/django2.0-course,False,Django2.0视频教程相关代码(杨仕航)
+django-ecommerce,justdjango/django-ecommerce,False,An e-commerce website built with Django
+django-shop,awesto/django-shop,False,A Django based shop system
+DjangoUeditor,zhangfisher/DjangoUeditor,False,DjangoUeditor
+django-sspanel,Ehco1996/django-sspanel,False,用 diango 开发的 shadowsocks 面板
+graphene-django,graphql-python/graphene-django,False,Integrate GraphQL into your Django project.
+django-jet,geex-arts/django-jet,False,Modern responsive template for the Django admin interface with improved functionality. We are proud to announce completely new Jet. Please check out Live Demo
+django-debug-toolbar,jazzband/django-debug-toolbar,False,A configurable set of panels that display various debug information about the current request/response.
+django-filter,carltongibson/django-filter,False,A generic system for filtering Django QuerySets based on user selections
+django-ckeditor,django-ckeditor/django-ckeditor,False,Django admin CKEditor integration.
+django-taggit,jazzband/django-taggit,False,Simple tagging for django
+django-storages,jschneier/django-storages,False,https://django-storages.readthedocs.io/
+channels,django/channels,False,Developer-friendly asynchrony for Django
+django-grappelli,sehmaschine/django-grappelli,False,A jazzy skin for the Django Admin-Interface (official repository).
+django-DefectDojo,DefectDojo/django-DefectDojo,False,DefectDojo is a DevSecOps and vulnerability management tool.
+djangoproject.com,django/djangoproject.com,False,Source code to djangoproject.com
+djangorestframework-simplejwt,jazzband/djangorestframework-simplejwt,False,A JSON Web Token authentication plugin for the Django REST Framework.
+flask,pallets/flask,False,The Python micro framework for building web applications.
+flasky,miguelgrinberg/flasky,False,"Companion code to my O'Reilly book ""Flask Web Development"", second edition."
+helloflask,greyli/helloflask,False,"Hello, Flask!"
+awesome-flask,humiaozuzu/awesome-flask,False,A curated list of awesome Flask resources and plugins
+flask-website,pallets/flask-website,False,"The Flask website, built with Flask!"
+flask-admin,flask-admin/flask-admin,False,Simple and extensible administrative interface framework for Flask
+flask-restful,flask-restful/flask-restful,False,Simple framework for creating REST APIs
+flask-login,maxcountryman/flask-login,False,Flask user session management.
+flaskbb,flaskbb/flaskbb,False,A classic Forum Software in Python using Flask.
+flask-boilerplate,realpython/flask-boilerplate,False,"Boilerplate template for a Python Flask application with Flask-SQLAlchemy, Flask-WTF, Fabric, Coverage, and Bootstrap"
+flask-sqlalchemy,pallets-eco/flask-sqlalchemy,False,Adds SQLAlchemy support to Flask
+FlaskIntroduction,jakerieger/FlaskIntroduction,False,Repo for my tutorial on freeCodeCamp.org
+discover-flask,realpython/discover-flask,False,Full Stack Web Development with Flask.
+cookiecutter-flask,cookiecutter-flask/cookiecutter-flask,False,"A flask template with Bootstrap, asset bundling+minification with webpack, starter templates, and registration/authentication. For use with cookiecutter."
+flask,roytuts/flask,False,
+Flask-AppBuilder,dpgaspar/Flask-AppBuilder,False,"Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/"
+Flask-SocketIO,miguelgrinberg/Flask-SocketIO,False,Socket.IO integration for Flask applications.
+flask-bootstrap,mbr/flask-bootstrap,False,Ready-to-use Twitter-bootstrap for use in Flask.
+rest-apis-flask-python,tecladocode/rest-apis-flask-python,False,"Projects and e-book for our course, REST APIs with Flask and Python"
+flask-restplus,noirbizarre/flask-restplus,False,"Fully featured framework for fast, easy and documented API development with Flask"
+FlaskSeries,jimdevops19/FlaskSeries,False,This is the Code from my Flask Series - JimShapedCoding. Each Folder is a checkpoint where we stopped at that particular episode number
+flask-base,hack4impact/flask-base,False,"A simple Flask boilerplate app with SQLAlchemy, Redis, User Authentication, and more."
+flaskr-tdd,mjhea0/flaskr-tdd,False," Flaskr: Intro to Flask, Test-Driven Development (TDD), and JavaScript"
+python-sample-vscode-flask-tutorial,microsoft/python-sample-vscode-flask-tutorial,False,Sample code for the Flask tutorial in the VS Code documentation
+flaskSaaS,alectrocute/flaskSaaS,False,"A great starting point to build your SaaS in Flask & Python, with Stripe subscription billing 🚀"
+xzceb-flask_eng_fr,ibm-developer-skills-network/xzceb-flask_eng_fr,False,flask_enf_fr
+flask-security,mattupstate/flask-security,False,Quick and simple security for Flask applications
+flaskex,anfederico/flaskex,False,Simple flask example for quick prototypes and small applications
+flask-oauthlib,lepture/flask-oauthlib,False,YOU SHOULD USE https://github.com/lepture/authlib
+uwsgi-nginx-flask-docker,tiangolo/uwsgi-nginx-flask-docker,False,Docker image with uWSGI and Nginx for Flask applications in Python running in a single container. Optionally with Alpine Linux.
+requests,psf/requests,False,"A simple, yet elegant, HTTP library."
+Requests,WordPress/Requests,False,Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.
+requests-html,psf/requests-html,False,Pythonic HTML Parsing for Humans™
+requests-oauthlib,requests/requests-oauthlib,False,OAuthlib support for Python-Requests!
+requests-for-research,openai/requests-for-research,False,A living collection of deep learning problems
+jsr,mercyblitz/jsr,False,Java Specification Requests
+requests,asmcos/requests,False,A golang HTTP client library. Salute to python requests.
+request,request/request,False,🏊🏾 Simplified HTTP request client.
+read_requests,wangshunping/read_requests,False,python requests 源码阅读,学习更pythonic 的python代码写法。
+cpr,libcpr/cpr,False,"C++ Requests: Curl for People, a spiritual port of Python Requests."
+requests-futures,ross/requests-futures,False,Asynchronous Python HTTP Requests for Humans using Futures
+robotframework-requests,MarketSquare/robotframework-requests,False,Robot Framework keyword library wrapper for requests
+grequests,spyoungtech/grequests,False,Requests + Gevent = <3
+pull-requests,btholt/pull-requests,False,A sample repo for the Intro to Web Dev course for Frontend Masters
+reqwest,ded/reqwest,False,browser asynchronous http requests
+requests-cache,requests-cache/requests-cache,False,Persistent HTTP cache for python requests
+WordPress,WordPress/WordPress,False,"WordPress, Git-ified. This repository is just a mirror of the WordPress subversion repository. Please do not send pull requests. Submit pull requests to https://github.com/WordPress/wordpress-develop and patches to https://core.trac.wordpress.org/ instead."
+lazyweb-requests,h5bp/lazyweb-requests,False,Get projects and ideas built by the community
+requests3,kennethreitz-archive/requests3,False,"Requests 3.0, for Humans and Machines, alike. 🤖"
+semantic-pull-requests,zeke/semantic-pull-requests,False,:robot: Let the robots take care of the semantic versioning
+collectd,collectd/collectd,False,The system statistics collection daemon. Please send Pull Requests here!
+learn4haskell,kowainik/learn4haskell,False,👩🏫 👨🏫 Learn Haskell basics in 4 pull requests
+HeaderEditor,FirefoxBar/HeaderEditor,False,"Manage browser's requests, include modify the request headers and response headers, redirect requests, cancel requests"
+c-ares,c-ares/c-ares,False,A C library for asynchronous DNS requests
+requests,wangluozhe/requests,False,用于快速请求HTTP或HTTPS,并支持修改ja3指纹
+vscode-pull-request-github,microsoft/vscode-pull-request-github,False,GitHub Pull Requests for Visual Studio Code
+laravel-query-builder,spatie/laravel-query-builder,False,Easily build Eloquent queries from API requests
+requests-ip-rotator,Ge0rg3/requests-ip-rotator,False,A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.
+hound,houndci/hound,False,Automated code review for GitHub pull requests.
+mention-bot,facebookarchive/mention-bot,False,Automatically mention potential reviewers on pull requests.
+LollipopShowcase,mikepenz/LollipopShowcase,False,"A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar"
+lolMiner-releases,Lolliedieb/lolMiner-releases,False,
+LolliPin,omadahealth/LolliPin,False,A Material design Android pincode library. Supports Fingerprint.
+LOLBAS,LOLBAS-Project/LOLBAS,False,Living Off The Land Binaries And Scripts - (LOLBins and LOLScripts)
+lolcommits,lolcommits/lolcommits,False,:camera: git-based selfies for software developers
+LOLBAS,api0cradle/LOLBAS,False,Living Off The Land Binaries And Scripts - (LOLBins and LOLScripts)
+lolcat,busyloop/lolcat,False,Rainbows and unicorns!
+LollipopGo,Golangltd/LollipopGo,False,"稳定分支2.9.X 版本已更新,由【Golang语言游戏服务器】维护,全球服游戏服务器及区域服框架,目前协议支持websocket、http、KCP、TCP及RPC,采用状态同步(帧同步内测),愿景:打造MMO多人竞技游戏框架! 功能持续更新中... ..."
+LOL,RozDavid/LOL,False,LOL: Lidar-only Odometry and Localization in 3D point cloud maps
+ZuAnBot,liuke-wuhan/ZuAnBot,False,祖安助手:英雄联盟(League Of Legends)一键喷人,LOL游戏和客户端中可用。只为反击喷子!
+R3nzSkin,R3nzTheCodeGOD/R3nzSkin,False,Skin changer for League of Legends (LOL)
+PreLollipopTransition,takahirom/PreLollipopTransition,False,Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices.
+primitive.js,ondras/primitive.js,False,JS port of primitive.lol
+hh-lol-prophet,real-web-world/hh-lol-prophet,False,"lol 对局先知 上等马 牛马分析程序 选人阶段判断己方大爹 大坑, 明确对局目标 基于lol client api 合法不封号"
+LollipopContactsRecyclerViewFastScroller,AndroidDeveloperLB/LollipopContactsRecyclerViewFastScroller,False,A sample of how to mimic the way that the contacts app handles a Fast-Scroller for a RecyclerView
+lolimeow,baomihuahua/lolimeow,False,wordpress主题 lolimeow
+Lol,cpeikert/Lol,False,Λ ⚬ λ: Functional Lattice Cryptography
+lol_dba,plentz/lol_dba,False,"lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts."
+LoLHuman,LoL-Human/LoLHuman,False,LoL Human APIs
+keys-generator,SjorsO/keys-generator,False,Key generator for https://keys.lol
+lolviz,parrt/lolviz,False,"A simple Python data-structure visualization tool for lists of lists, lists, dictionaries; primarily for use in Jupyter notebooks / presentations"
+Android-Material-Design-for-pre-Lollipop,Suleiman19/Android-Material-Design-for-pre-Lollipop,False,"Various UI implementations, animations & effects based on Material Design compatible with pre Lollipop devices as well. (Work in progess)"
+The-LoliBot-MD,elrebelde21/The-LoliBot-MD,False,"𝙃𝙤𝙡𝙖 👋 𝘽𝙞𝙚𝙣𝙫𝙚𝙣𝙞𝙙𝙤 🤗 𝙚𝙨𝙩𝙚 𝙚𝙨 𝙚𝙡 𝙧𝙚𝙥𝙤𝙨𝙞𝙩𝙤𝙧𝙞𝙤 𝙤𝙛𝙞𝙘𝙞𝙖𝙡 𝙙𝙚𝙡 𝙏𝙝𝙚 𝙇𝙤𝙡𝙞𝘽𝙤𝙩-𝙈𝘿. 𝘼𝙦𝙪𝙞 𝙨𝙚 𝙧𝙚𝙖𝙡𝙞𝙯𝙖𝙣 𝙖𝙘𝙩𝙪𝙖𝙡𝙞𝙯𝙖𝙘𝙞𝙤𝙣𝙚𝙨, 𝙎𝙞 𝙩𝙚 𝙖𝙜𝙧𝙖𝙙𝙖 𝙚𝙡 𝙗𝙤𝙩 𝙢𝙚 𝙥𝙪𝙚𝙙𝙚 𝙧𝙚𝙜𝙖𝙡𝙖𝙧 𝙪𝙣𝙖 🌟, 𝙚𝙨𝙥𝙚𝙧𝙤 𝙦𝙪𝙚 𝙜𝙪𝙨𝙩𝙚 𝙚𝙡 𝙗𝙤𝙩 😊"
+LOLBAS222,homjxi0e/LOLBAS222,False,"APT || Execution || Launch || APTs || ( Authors harr0ey, bohops )"
+lol-html,cloudflare/lol-html,False,Low output latency streaming HTML parser/rewriter with CSS selector-based API
+lolcode-spec,justinmeza/lolcode-spec,False,LOLCODE language specification archives and development.
+sinatras-hat,nakajima/sinatras-hat,False,lol
+lollipops,joiningdata/lollipops,False,Lollipop-style mutation diagrams for annotating genetic variations.
+loli_profiler,Tencent/loli_profiler,False,Memory instrumentation tool for android app&game developers.
+omg.lol,neatnik/omg.lol,False,Cool stuff for omg.lol
+json,nlohmann/json,False,JSON for Modern C++
+json,serde-rs/json,False,Strongly typed JSON library for Rust
+json-server,typicode/json-server,False,Get a full fake REST API with zero coding in less than 30 seconds (seriously)
+JsonPath,json-path/JsonPath,False,Java JsonPath implementation
+json,flori/json,False,JSON implementation for Ruby
+jsonschema2pojo,joelittlejohn/jsonschema2pojo,False,"Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc"
+jsoncpp,open-source-parsers/jsoncpp,False,A C++ library for interacting with JSON.
+SwiftyJSON,SwiftyJSON/SwiftyJSON,False,The better way to deal with JSON data in Swift.
+JSON-js,douglascrockford/JSON-js,False,JSON in JavaScript
+jsoneditor,josdejong/jsoneditor,False,"A web-based tool to view, edit, format, and validate JSON"
+json,konklone/json,False,"A free, in-browser JSON to CSV converter."
+json,trentm/json,False,"A ""json"" command for massaging JSON on your Unix command line."
+json-tutorial,miloyip/json-tutorial,False,从零开始的 JSON 库教程
+Newtonsoft.Json,JamesNK/Newtonsoft.Json,False,Json.NET is a popular high-performance JSON framework for .NET
+JSONKit,johnezang/JSONKit,False,Objective-C JSON
+cJSON,DaveGamble/cJSON,False,Ultralightweight JSON parser in ANSI C
+json11,dropbox/json11,False,A tiny JSON library for C++11.
+jsonmodel,jsonmodel/jsonmodel,False,"Magical Data Modeling Framework for JSON - allows rapid creation of smart data models. You can use it in your iOS, macOS, watchOS and tvOS apps."
+jsoncrack.com,AykutSarac/jsoncrack.com,False,⭐️ Transform data chaos into clarity with JSON Crack - the ultimate JSON visualization solution.
+JSON-java,stleary/JSON-java,False,A reference implementation of a JSON package in Java.
+json,rsanchez/json,False,Output ExpressionEngine data in JSON format.
+node-jsonwebtoken,auth0/node-jsonwebtoken,False,JsonWebToken implementation for node.js http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html
+JSONExport,Ahmed-Ali/JSONExport,False,"JSONExport is a desktop application for Mac OS X which enables you to export JSON objects as model classes with their associated constructors, utility methods, setters and getters in your favorite language."
+react-jsonschema-form,rjsf-team/react-jsonschema-form,False,A React component for building Web forms from JSON Schema.
+json,taocpp/json,False,C++ header-only JSON library
+json5,json5/json5,False,JSON5 — JSON for Humans
+json2csv,zemirco/json2csv,False,Convert json to csv with column titles
+json-editor,jdorn/json-editor,False,JSON Schema Based Editor
+ArduinoJson,bblanchon/ArduinoJson,False,📟 JSON library for Arduino and embedded C++. Simple and efficient.
+jq,stedolan/jq,False,Command-line JSON processor
diff --git a/HW#12Lecture#15/.idea/.gitignore b/HW#12Lecture#15/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/HW#12Lecture#15/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/HW#12Lecture#15/.idea/HW#12Lecture#15.iml b/HW#12Lecture#15/.idea/HW#12Lecture#15.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/HW#12Lecture#15/.idea/HW#12Lecture#15.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml b/HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#12Lecture#15/.idea/misc.xml b/HW#12Lecture#15/.idea/misc.xml
new file mode 100644
index 0000000..1c4cab4
--- /dev/null
+++ b/HW#12Lecture#15/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/HW#12Lecture#15/.idea/modules.xml b/HW#12Lecture#15/.idea/modules.xml
new file mode 100644
index 0000000..e135619
--- /dev/null
+++ b/HW#12Lecture#15/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#12Lecture#15/.idea/vcs.xml b/HW#12Lecture#15/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/HW#12Lecture#15/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#12Lecture#15/main.py b/HW#12Lecture#15/main.py
new file mode 100644
index 0000000..59a7868
--- /dev/null
+++ b/HW#12Lecture#15/main.py
@@ -0,0 +1,43 @@
+import threading
+from urllib.request import urlopen
+import json
+
+
+def get_course(url):
+ response = urlopen(url).read().decode('utf-8')
+ res = json.loads(response)
+ return res
+
+
+def get_course_pb():
+ url = "https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=5"
+ res = get_course(url)
+ #print(res[1]['buy'])
+ return res[1]['buy']
+
+
+def get_course_nbu():
+ url = 'https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json'
+ res = get_course(url)
+ #print(res[24]['rate'])
+ return res[24]['rate']
+
+
+def get_best_course():
+
+ print (f'Best course is {max(float(get_course_pb()), float(get_course_nbu()))}')
+ return max(float(get_course_pb()), float(get_course_nbu()))
+
+
+
+if __name__ == "__main__":
+ thread1 = threading.Thread(target=get_course_pb)
+ thread2 = threading.Thread(target=get_course_nbu)
+ thread3 = threading.Thread(target=get_best_course)
+
+ thread1.start()
+ thread2.start()
+ thread1.join()
+ thread2.join()
+ thread3.start()
+
diff --git a/HW#5 Advanced classes/Cards.py b/HW#5 Advanced classes/Cards.py
new file mode 100644
index 0000000..ca19afe
--- /dev/null
+++ b/HW#5 Advanced classes/Cards.py
@@ -0,0 +1,49 @@
+import random
+
+
+class Cards():
+ RANKS = list(range(2, 11)) + list('JQKA')
+ SUITS = ['\u2660', '\u2665', '\u2666', '\u2663']
+
+ def __init__(self):
+ self.rank = self.RANKS
+ self.suits = self.SUITS
+
+ def __repr__(self):
+ return f"{self.magic_cards()}"
+
+ def create_deck(self):
+ deck = []
+ deck_list = [(str(i), j) for i in self.RANKS for j in self.SUITS]
+ for i in deck_list:
+ deck.append("".join(i))
+ return deck
+
+ def generate_card(self, n=1):
+ cards_list = []
+ for i in range(n):
+ cards_list.append(random.choice(self.create_deck()))
+ return cards_list
+
+ def magic_cards():
+ card = Cards()
+ from datetime import datetime
+ print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n"
+ f"How many cards will you get?\n -->")
+ num_cards = input()
+ try:
+ num_cards = int(num_cards)
+ if 0 < int(num_cards) < 5:
+ week_days_list = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
+ get_cards = card.generate_card(int(num_cards))
+ num_cards -= 1
+ print(f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n"
+ f"--->>>{week_days_list[datetime.now().weekday() + 1]}<<<---")
+ else:
+ print('too many cards, you probably need to see a fortune teller')
+ except ValueError:
+ print("it seems that tomorrow......\n you will learn how letters differ from numbers")
+
+if __name__ == '__main__':
+ Cards()
+x = Cards()
diff --git a/HW#5 Advanced classes/Fortune.py b/HW#5 Advanced classes/Fortune.py
new file mode 100644
index 0000000..704ed95
--- /dev/null
+++ b/HW#5 Advanced classes/Fortune.py
@@ -0,0 +1,18 @@
+from Cards import Cards as game
+
+res = 'Friend, do not believe in delusions,\n we ourselves are the creators of our destiny'
+def few_questions():
+ print('Hello friend, I heard you are looking for a seer?')
+ if input('y/n ??? \n >---') == 'y':
+ print('Do you believe in fortune telling?')
+ if input('y/n ??? \n >---') == 'y':
+ print('Then you are in luck,\n'
+ 'because I know how to predict fate on cards')
+ game.magic_cards()
+ print ('I hope you understand my ' + res)
+ else:
+ print("I'm happy for you my " + res)
+ else:
+ print("That's good my " + res)
+
+few_questions()
\ No newline at end of file
diff --git a/HW#7 Lecture#9/CardsExtendet.py b/HW#7 Lecture#9/CardsExtendet.py
new file mode 100644
index 0000000..33f74ac
--- /dev/null
+++ b/HW#7 Lecture#9/CardsExtendet.py
@@ -0,0 +1,173 @@
+import random
+
+
+class CardDeck():
+ LOW_CARDS = list(range(2, 11))
+ HI_CARDS = list('JQKA')
+ SUITS = ['\u2660', '\u2665', '\u2666', '\u2663']
+
+ def __init__(self):
+ self.suits = self.SUITS
+ self.ranks = self.LOW_CARDS + self.HI_CARDS
+ self.shufle_count = 0
+ self.deck = self.create_deck()
+
+ def __repr__(self):
+ return f'{self.deck}'
+
+ def create_deck(self):
+ deck = []
+ deck_list = [(str(i), j) for i in self.ranks for j in self.suits]
+ for i in deck_list:
+ deck.append("".join(i))
+ return deck
+
+ def generate_card(self, n=1):
+ # Метод що вибирає мінімум одну рандомну карту з колоди
+ cards_list = []
+ for i in range(n):
+ cards_list.append(random.choice(self.deck))
+ return cards_list
+
+ def shuffle(self):
+ random.shuffle(self.deck)
+ self.shufle_count += 1
+
+ def __len__(self):
+ return len(self.deck)
+
+ def __getitem__(self, out_card):
+ if isinstance(out_card, int):
+ if out_card < len(self.deck):
+ return self.deck.pop(out_card)
+ else:
+ print('Колода менша за ваші амбіції')
+ else:
+ raise TypeError('Потрібно вказати номер карти')
+
+ def __add__(self, add_card):
+ if isinstance(add_card, list):
+ return self.deck + list(add_card)
+ else:
+ print('додати можна лише список')
+
+ def __sub__(self, out_cards):
+ if isinstance(out_cards, list):
+ for i in out_cards:
+ if self.__contains__(i):
+ self.deck.remove(i)
+
+ else:
+ print(f'Карта {i} мабуть десь в рукаві')
+ return self.deck
+ else:
+ print('потрібен список карт')
+
+ def __contains__(self, card):
+ return card in self.deck
+
+ def __eq__(self, other):
+ return sorted(self.deck) < sorted(other.deck)
+
+ def __gt__(self, other):
+ return sorted(self.deck) < sorted(other.deck)
+
+ def __lt__(self, other):
+ return sorted(self.deck) > sorted(other.deck)
+
+ def magic_cards(self):
+ from datetime import datetime
+ print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n"
+ f"How many cards will you get?\n -->")
+ num_cards = input()
+ try:
+ int(num_cards)
+ if 0 < int(num_cards) < 5:
+ week_days_list = ['monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
+ get_cards = self.generate_card(int(num_cards))
+ num_cards -= 1
+ print(
+ f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n"
+ f"--->>>{week_days_list[datetime.now().weekday()]}<<<---")
+ else:
+ print('too many cards you probably need to see a fortune teller')
+ except ValueError:
+ print("it seems that tomorrow......\n you will learn how letters differ from numbers")
+
+ def __bool__(self):
+ return bool(self.deck) > 0 and self.shufle_count > 0
+
+
+class SmallDeck(CardDeck):
+ LOW_CARDS = list(range(6, 11))
+
+ def __init__(self):
+ super().__init__()
+
+
+class ClassicDeck(CardDeck):
+ def __init__(self):
+ super().__init__()
+
+
+if __name__ == '__main__':
+ x = ClassicDeck()
+ y = ClassicDeck()
+ s = SmallDeck()
+ n = ['2♠', '2♦', '3♠']
+ n2 = ['2♠']
+
+ # #для перевірки shuffle()
+ # print(x)
+ # x.shuffle()
+ # print(x)
+
+ # #для перевірки __len__()
+ # print(len(x))
+
+ # #для перевірки __getitem__()
+ # print(x[2])
+ # print(x[55])
+
+ # #для перевірки __add__
+ # print (x + n)
+
+ # #для перевірки __sub__()
+ # print(x-n)
+ # x-n2
+
+ # #для перевірки __contains__()
+ # print(x)
+ # n = '2♠'
+ # print(n)
+ # print(n in x)
+
+ # # для перевірки __eq__()
+ # y.shuffle()
+ # print(x)
+ # print(y)
+ # print (x == y)
+ # print(x)
+ # print(s)
+ # print (x == s)
+
+ # #для перевірки __gt__() та __lt__
+ # print(x < s)
+ # print(x > s)
+
+ # #для перевірки __bool__
+ # print(bool(x))
+ # x.shuffle()
+ # print(bool(x))
+
+ # #ітерація колоди
+ # i = iter(x)
+ # print(next(i))
+ # print(next(i))
+ # print(next(i))
+ # print(next(i))
+ # print(next(i))
+ # print(type(x))
+ ## наскільки я зрозумів ітератор працює завдяки наякності метода __getitem__() що дозволяє переберати елементи.
+
+
diff --git a/HW#8 Lecture#10/.idea/.gitignore b/HW#8 Lecture#10/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/HW#8 Lecture#10/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml b/HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml b/HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#8 Lecture#10/.idea/misc.xml b/HW#8 Lecture#10/.idea/misc.xml
new file mode 100644
index 0000000..5bb15ec
--- /dev/null
+++ b/HW#8 Lecture#10/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/HW#8 Lecture#10/.idea/modules.xml b/HW#8 Lecture#10/.idea/modules.xml
new file mode 100644
index 0000000..ae38987
--- /dev/null
+++ b/HW#8 Lecture#10/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#8 Lecture#10/.idea/vcs.xml b/HW#8 Lecture#10/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/HW#8 Lecture#10/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#8 Lecture#10/CardsExtendet.py b/HW#8 Lecture#10/CardsExtendet.py
new file mode 100644
index 0000000..006da1e
--- /dev/null
+++ b/HW#8 Lecture#10/CardsExtendet.py
@@ -0,0 +1,209 @@
+import random
+import shelve
+
+class CardDeck():
+ LOW_CARDS = list(range(2, 11))
+ HI_CARDS = list('JQKA')
+ SUITS = ['\u2660', '\u2665', '\u2666', '\u2663']
+
+ def __init__(self):
+ self.suits = self.SUITS
+ self.ranks = self.LOW_CARDS + self.HI_CARDS
+ self.shufle_count = 0
+ self.deck = self.create_deck()
+
+ def __repr__(self):
+ return f'{self.deck}'
+
+ def create_deck(self):
+ deck = []
+ deck_list = [(str(i), j) for i in self.ranks for j in self.suits]
+ for i in deck_list:
+ deck.append("".join(i))
+ return deck
+
+ def generate_card(self, n=1):
+ # Метод що вибирає мінімум одну рандомну карту з колоди
+ cards_list = []
+ for i in range(n):
+ cards_list.append(random.choice(self.deck))
+ return cards_list
+
+ def shuffle(self):
+ random.shuffle(self.deck)
+ self.shufle_count += 1
+
+ def __len__(self):
+ return len(self.deck)
+
+ def __getitem__(self, out_card):
+ if isinstance(out_card, int):
+ if out_card < len(self.deck):
+ return self.deck.pop(out_card)
+ else:
+ print('Колода менша за ваші амбіції')
+ else:
+ raise TypeError('Потрібно вказати номер карти')
+
+ def __add__(self, add_card):
+ if isinstance(add_card, list):
+ return self.deck + list(add_card)
+ else:
+ print('додати можна лише список')
+
+ def __sub__(self, out_cards):
+ if isinstance(out_cards, list):
+ for i in out_cards:
+ if self.__contains__(i):
+ self.deck.remove(i)
+
+ else:
+ print(f'Карта {i} мабуть десь в рукаві')
+ return self.deck
+ else:
+ print('потрібен список карт')
+
+ def __contains__(self, card):
+ return card in self.deck
+
+ def __eq__(self, other):
+ return sorted(self.deck) < sorted(other.deck)
+
+ def __gt__(self, other):
+ return sorted(self.deck) < sorted(other.deck)
+
+ def __lt__(self, other):
+ return sorted(self.deck) > sorted(other.deck)
+
+ def magic_cards(self):
+ from datetime import datetime
+ print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n"
+ f"How many cards will you get?\n -->")
+ num_cards = input()
+ try:
+ int(num_cards)
+ if 0 < int(num_cards) < 5:
+ week_days_list = ['monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
+ get_cards = self.generate_card(int(num_cards))
+ num_cards -= 1
+ print(
+ f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n"
+ f"--->>>{week_days_list[datetime.now().weekday()]}<<<---")
+ else:
+ print('too many cards you probably need to see a fortune teller')
+ except ValueError:
+ print("it seems that tomorrow......\n you will learn how letters differ from numbers")
+
+ def __bool__(self):
+ return bool(self.deck) > 0 and self.shufle_count > 0
+
+ def deck_write(self, deck_name, format='shelve'):
+ if format == 'shelve':
+ with shelve.open(str(deck_name)) as file:
+ file[deck_name] = self.deck
+ print(f'Deck {deck_name} is saved in shelve format')
+ elif format == 'txt':
+ with open('DeckFile', 'w') as file:
+ file.write(f'{self.deck}')
+ print(f'Deck {deck_name} is saved in txt format')
+ else:
+ print('Write format can be only shelve or txt')
+
+
+
+ @classmethod
+ def deck_load(self, deck_name, format='shelve'):
+ if format == 'shelve':
+ with shelve.open(str(deck_name)) as file:
+ print(file[deck_name])
+ return file[deck_name]
+ elif format == 'txt':
+ with open('DeckFile', 'r') as file:
+ print(file.read())
+ return file.read()
+ else:
+ print('Format can be only shelve or txt')
+
+
+class SmallDeck(CardDeck):
+ LOW_CARDS = list(range(6, 11))
+
+ def __init__(self):
+ super().__init__()
+
+
+class ClassicDeck(CardDeck):
+ def __init__(self):
+ super().__init__()
+
+
+if __name__ == '__main__':
+ x = ClassicDeck()
+ y = ClassicDeck()
+ s = SmallDeck()
+ n = ['2♠', '2♦', '3♠']
+ n2 = ['2♠']
+
+ # #для перевірки shuffle()
+ # print(x)
+ # x.shuffle()
+ # print(x)
+
+ # #для перевірки __len__()
+ # print(len(x))
+
+ # #для перевірки __getitem__()
+ # print(x[2])
+ # print(x[55])
+
+ # #для перевірки __add__
+ # print (x + n)
+
+ # #для перевірки __sub__()
+ # print(x-n)
+ # x-n2
+
+ # #для перевірки __contains__()
+ # print(x)
+ # n = '2♠'
+ # print(n)
+ # print(n in x)
+
+ # # для перевірки __eq__()
+ # y.shuffle()
+ # print(x)
+ # print(y)
+ # print (x == y)
+ # print(x)
+ # print(s)
+ # print (x == s)
+
+ # #для перевірки __gt__() та __lt__
+ # print(x < s)
+ # print(x > s)
+
+ # #для перевірки __bool__
+ # print(bool(x))
+ # x.shuffle()
+ # print(bool(x))
+
+ # #ітерація колоди
+ # i = iter(x)
+ # print(next(i))
+ # print(next(i))
+ # print(next(i))
+ # print(next(i))
+ # print(next(i))
+ # print(type(x))
+ ## наскільки я зрозумів ітератор працює завдяки наякності метода __getitem__() що дозволяє переберати елементи.
+
+ #перевірка запису в форматі txt
+ x.deck_write('classic', 'txt')
+ x.deck_load('classic', 'txt')
+
+ # # перевірка запису в форматі shalve
+ # s.deck_write('small')
+ # s.deck_load('small')
+
+
+
diff --git a/HW#8 Lecture#10/DeckFile b/HW#8 Lecture#10/DeckFile
new file mode 100644
index 0000000..e08d98b
--- /dev/null
+++ b/HW#8 Lecture#10/DeckFile
@@ -0,0 +1 @@
+['2♠', '2♥', '2♦', '2♣', '3♠', '3♥', '3♦', '3♣', '4♠', '4♥', '4♦', '4♣', '5♠', '5♥', '5♦', '5♣', '6♠', '6♥', '6♦', '6♣', '7♠', '7♥', '7♦', '7♣', '8♠', '8♥', '8♦', '8♣', '9♠', '9♥', '9♦', '9♣', '10♠', '10♥', '10♦', '10♣', 'J♠', 'J♥', 'J♦', 'J♣', 'Q♠', 'Q♥', 'Q♦', 'Q♣', 'K♠', 'K♥', 'K♦', 'K♣', 'A♠', 'A♥', 'A♦', 'A♣']
\ No newline at end of file
diff --git a/HW#8 Lecture#10/DepWithOneYear.py b/HW#8 Lecture#10/DepWithOneYear.py
new file mode 100755
index 0000000..d67ba12
--- /dev/null
+++ b/HW#8 Lecture#10/DepWithOneYear.py
@@ -0,0 +1,78 @@
+
+#!/usr/bin/env python3
+
+
+USAGE = """USAGE: {script} initial_sum percent fixed_period set_period
+
+\tCalculate deposit yield. See script source for more details.
+"""
+USAGE = USAGE.strip()
+
+
+def deposit(initial_sum, percent, fixed_period, set_period):
+ """Calculate deposit yield."""
+ per = percent / 100
+ one_year = (1 + per)
+ growth_five = one_year ** 5
+ growth_ten = one_year ** 10
+ growth_set = one_year ** (set_period / fixed_period)
+ res = f"One month yield: {'%.2f' % (initial_sum * one_year / 12)}\n" \
+ f"One year yield: {'%.2f' % (initial_sum * one_year)}\n" \
+ f"Five year yield: {'%.2f' % (initial_sum * growth_five)}\n" \
+ f"Ten year yield: {'%.2f' % (initial_sum * growth_ten)}\n" \
+ f"Set period yield: {'%.2f' % (initial_sum * growth_set)}"
+ write_deposit(res)
+
+
+ return res
+
+def read_deposit():
+ initial_sum, percent, fixed_period, set_period = None, None, None, None
+ try:
+ with open('DepositArgs.txt', 'r', encoding='cp1251') as file:
+ lines = file.readlines()
+
+ try:
+ initial_sum = float(lines[0].split('=')[1])
+ percent = float(lines[1].split('=')[1])
+ fixed_period = float(lines[2].split('=')[1])
+ set_period = float(lines[3].split('=')[1])
+ except:
+ print('Something goes wrong, check file data')
+ res = deposit(initial_sum, percent, fixed_period, set_period)
+ write_deposit(res)
+ print(res)
+ return res
+ except FileNotFoundError:
+ print('File is missing')
+
+def write_deposit(res):
+ with open('DepositArgs.txt', 'a')as file:
+ file.write(f'\n{res}')
+
+
+
+
+def main(args):
+ """Gets called when run as a script."""
+ if len(args) != 4 + 1:
+ exit(USAGE.format(script=args[0]))
+
+ args = args[1:]
+ initial_sum, percent, fixed_period, set_period = map(float, args)
+
+ # same as
+ # initial_sum = float(args[0])
+ # percent = float(args[1])
+ # ...
+
+ res = deposit(initial_sum, percent, fixed_period, set_period)
+ print(res)
+
+read_deposit()
+
+# if __name__ == '__main__':
+# import sys
+#
+# main(sys.argv)
+
diff --git a/HW#8 Lecture#10/DepositArgs.txt b/HW#8 Lecture#10/DepositArgs.txt
new file mode 100644
index 0000000..09b9887
--- /dev/null
+++ b/HW#8 Lecture#10/DepositArgs.txt
@@ -0,0 +1,15 @@
+initial_sum=5000
+percent=9
+fixed_period=1
+set_period=3
+
+One month yield: 454.17
+One year yield: 5450.00
+Five year yield: 7693.12
+Ten year yield: 11836.82
+Set period yield: 6475.15
+One month yield: 454.17
+One year yield: 5450.00
+Five year yield: 7693.12
+Ten year yield: 11836.82
+Set period yield: 6475.15
\ No newline at end of file
diff --git a/HW#8 Lecture#10/small b/HW#8 Lecture#10/small
new file mode 100644
index 0000000..939abea
Binary files /dev/null and b/HW#8 Lecture#10/small differ
diff --git a/HW#9Lecture#12/.idea/.gitignore b/HW#9Lecture#12/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/HW#9Lecture#12/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/HW#9Lecture#12/.idea/HW#9.iml b/HW#9Lecture#12/.idea/HW#9.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/HW#9Lecture#12/.idea/HW#9.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml b/HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#9Lecture#12/.idea/misc.xml b/HW#9Lecture#12/.idea/misc.xml
new file mode 100644
index 0000000..4733bd8
--- /dev/null
+++ b/HW#9Lecture#12/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/HW#9Lecture#12/.idea/modules.xml b/HW#9Lecture#12/.idea/modules.xml
new file mode 100644
index 0000000..de1b1d1
--- /dev/null
+++ b/HW#9Lecture#12/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#9Lecture#12/.idea/vcs.xml b/HW#9Lecture#12/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/HW#9Lecture#12/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HW#9Lecture#12/first.py b/HW#9Lecture#12/first.py
new file mode 100644
index 0000000..0c779fb
--- /dev/null
+++ b/HW#9Lecture#12/first.py
@@ -0,0 +1,34 @@
+import time
+
+
+def base_decorator(j):
+ def iterator(func):
+ def wrapper(x, y):
+ print(j)
+ start_time = time.time()
+ func(x, y)
+ print(time.time() - start_time)
+
+ return wrapper
+ return iterator
+
+
+@base_decorator(5)
+def suma(x, y):
+ print(x + y)
+
+
+
+@base_decorator(123)
+def minus(x, y):
+ print(x - y)
+
+
+minus(8, 2)
+suma(8, 2)
+
+
+class A:
+ @staticmethod
+ def hello():
+ print("hello")
diff --git a/HW#9Lecture#12/red-Arrow/database/employees.json b/HW#9Lecture#12/red-Arrow/database/employees.json
new file mode 100644
index 0000000..ec5cd81
--- /dev/null
+++ b/HW#9Lecture#12/red-Arrow/database/employees.json
@@ -0,0 +1 @@
+[{"id": "1", "first_name": "qwe", "last_name": "qwe", "email": "qwe@qwe.qwe", "phone": "+380681111992"}]
\ No newline at end of file
diff --git a/HW#9Lecture#12/red-Arrow/helpers/__init__.py b/HW#9Lecture#12/red-Arrow/helpers/__init__.py
new file mode 100644
index 0000000..33afd8d
--- /dev/null
+++ b/HW#9Lecture#12/red-Arrow/helpers/__init__.py
@@ -0,0 +1,2 @@
+from .employee_helpers import *
+from .system_helpers import *
\ No newline at end of file
diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000..391fd62
Binary files /dev/null and b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc differ
diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc
new file mode 100644
index 0000000..b6a3174
Binary files /dev/null and b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc differ
diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/employee_helpers.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/employee_helpers.cpython-310.pyc
new file mode 100644
index 0000000..204aafa
Binary files /dev/null and b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/employee_helpers.cpython-310.pyc differ
diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc
new file mode 100644
index 0000000..f4cabe6
Binary files /dev/null and b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc differ
diff --git a/HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py b/HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py
new file mode 100644
index 0000000..cfc6af2
--- /dev/null
+++ b/HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py
@@ -0,0 +1,27 @@
+
+def is_email_valid(func):
+ def wrapper(x, email, y, a, z):
+ if "@" in email:
+ if "." in email.split("@")[1]:
+ func(x, email, y, a, z)
+ else:
+ print("Email invalid without dot!!!!")
+ else:
+ print("Email invalid without @ !!!!")
+ return wrapper
+
+
+def is_phone_valid(func):
+ def wrapper(x, y, a, z, phone):
+ if len(phone) == 13:
+ if phone[0] == '+':
+ func(x, y, a, z, phone)
+ else:
+ print('Phone number is wrong. It must start with +')
+ else:
+ print('Wrong phone number length. It must have 12 digits')
+ return wrapper
+
+
+
+
diff --git a/HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py b/HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py
new file mode 100644
index 0000000..58c2df5
--- /dev/null
+++ b/HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py
@@ -0,0 +1,51 @@
+from .system_helpers import save_to_file, get_file_data
+from .decorators_helpers import is_email_valid, is_phone_valid
+
+
+@is_email_valid
+@is_phone_valid
+def save(id, email, first_name, last_name, phone):
+ new_employee = {
+ "id": id,
+ "first_name": first_name,
+ "last_name": last_name,
+ "email": email,
+ "phone": phone,
+ }
+ save_to_file(new_employee)
+
+
+def get_all_employers():
+ employees = get_file_data()
+ for employee in employees:
+ print(employee["id"])
+ print(employee["email"])
+ print(employee["first_name"])
+ print(employee["last_name"])
+ print(employee["phone"])
+
+
+def get_employee_by_email(email):
+ employees = get_file_data()
+ for employee in employees:
+ if employee["email"] == email:
+ print(employee["id"])
+ print(employee["email"])
+ print(employee["first_name"])
+ print(employee["last_name"])
+ print(employee["phone"])
+
+
+def update_employee(id):
+ employers = get_file_data()
+ if isinstance(employers, list):
+ for employee in employers:
+ if employee['id'] == id:
+ employee["email"] = input("Employee email: ")
+ employee["first_name"] = input("Employee first name: ")
+ employee["last_name"] = input("Employee last Name: ")
+ employee["phone"] = input("Employee phone: ")
+ else:
+ print('No employee with this id')
+ else:
+ print('No employers to update')
\ No newline at end of file
diff --git a/HW#9Lecture#12/red-Arrow/helpers/system_helpers.py b/HW#9Lecture#12/red-Arrow/helpers/system_helpers.py
new file mode 100644
index 0000000..377b96c
--- /dev/null
+++ b/HW#9Lecture#12/red-Arrow/helpers/system_helpers.py
@@ -0,0 +1,17 @@
+import json
+
+
+def get_file_data():
+ file = open("database/employees.json", "r")
+ data_list = json.loads(file.read())
+ file.close()
+ return data_list
+
+
+def save_to_file(data: dict):
+ data_list = get_file_data()
+ data_list.append(data)
+ file = open("database/employees.json", "w")
+ data_in_json = json.dumps(data_list)
+ file.write(data_in_json)
+ file.close()
\ No newline at end of file
diff --git a/HW#9Lecture#12/red-Arrow/main.py b/HW#9Lecture#12/red-Arrow/main.py
new file mode 100644
index 0000000..91bd5d1
--- /dev/null
+++ b/HW#9Lecture#12/red-Arrow/main.py
@@ -0,0 +1,21 @@
+from helpers import save, get_all_employers, get_employee_by_email, update_employee
+
+
+while True:
+ print("1.Add new Employee\n2.Get all Employees\n3.Get employee by email\n4.Update employee")
+ flag = input("Choose menu item: ")
+ if flag == "1":
+ id = input('id: ')
+ email = input("Employee email: ")
+ first_name = input("Employee first name: ")
+ last_name = input("Employee last name: ")
+ phone_number = input("Employee phone number: ")
+ save(id, email, first_name, last_name, phone_number)
+ elif flag == "2":
+ get_all_employers()
+ elif flag == "3":
+ email_to_find = input("Type email of employee which you want to find: ")
+ get_employee_by_email(email_to_find)
+ elif flag == "4":
+ id_to_update = input("Type employee id to update: ")
+ update_employee(id_to_update)
diff --git a/OnceAtRoadblock.py b/OnceAtRoadblock.py
new file mode 100755
index 0000000..5fd91fc
--- /dev/null
+++ b/OnceAtRoadblock.py
@@ -0,0 +1,66 @@
+# !/usr/bin/env python3
+
+
+import random
+
+GREETENG = ["Теробора України !!! Стій! Хто Іде? Ану переклади пароль з англійської"]
+PASSWORD = ["hedgehog", "swan", "falcon", "ant-eater", "snake", "swallow", "hare", "bear", "squirrel", "rhinoceros"]
+N_DIALOG = ["Шо мовчиш?, москаль чи шо?", "Ану кажи пароль", "Микола, стрельни йому під ноги", "Ти шо німий?"]
+NO_DIALOG = ["Підіймай руки і йди сюди, якщо не німий, то ми тебе розговоримо"]
+UA_DIALOG = ["Вітаємо Козаче, Слава Україні!!!"]
+PL_DIALOG = ["Powitanie nasz Рolski przyjaciel! Chwała Ukrainie!!!"]
+GB_DIALOG = ["Welcome our English friend! Glory to Ukrain!!!"]
+RU_DIALOG = ["Ну от і все, гейм овер!. Микола доставай пакет, будемо депортірувати на \"родіну\"."]
+F_DIALOG = ["Йо Йо Йой, щось тут не те, ану ще разок",
+ "Микола ти це чув? Шукай гиляку. Ану ще раз",
+ "А ти часом не москаль? ану спробуй знову",
+ "Але ж ти і підозрілий! Давай знов ",
+ "Ану ше раз, поки Микола готує мотузку "]
+ATTEMPTS = 4
+T_PASSWORD = '> '
+
+
+def dialog():
+ """User dialog logic."""
+ password = PASSWORD[random.randrange(0, len(PASSWORD))]
+ print(f"{GREETENG}:\n{password}")
+ entry = input(T_PASSWORD).strip().lower() # user entry
+ attempts = ATTEMPTS
+ while attempts > 0:
+ if not entry and attempts == 1:
+ return print(NO_DIALOG)
+ elif not entry:
+ print(f"{N_DIALOG[random.randrange(0, len(N_DIALOG))]}")
+ print(password)
+ else:
+ if attempts == 1:
+ return print(RU_DIALOG)
+ for i in entry:
+ if i in "aeuoiy":
+ return print(GB_DIALOG)
+ for i in entry:
+ if i in "ąćęłńóśźż":
+ return print(PL_DIALOG)
+ for i in entry:
+ if i in "іїґє'":
+ return print(UA_DIALOG)
+ print(F_DIALOG[random.randrange(0, len(F_DIALOG))])
+ password = PASSWORD[random.randrange(0, len(PASSWORD))]
+ print(password)
+ entry = input(T_PASSWORD).strip().lower()
+ attempts -= 1
+
+
+
+def main(args):
+ script, *args = args
+ if args:
+ exit('Too many arguments. ' )
+
+ else:
+ dialog()
+
+if __name__ == '__main__':
+ import sys
+
+ main(sys.argv)
diff --git a/README.md b/README.md
index 1ab0ebc..775eb2e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,6 @@
Practice
+add another new string
command list
+first_branch
+
+check keys gpg
diff --git a/basicclasses.py b/basicclasses.py
new file mode 100644
index 0000000..4c33015
--- /dev/null
+++ b/basicclasses.py
@@ -0,0 +1,30 @@
+class Seeds:
+ def __init__(self, sowing_rate, ripeness_group, productivity_potential):
+ self.sowing_rate = sowing_rate
+ self.ripeness_group = ripeness_group
+ self.productivity_potential = productivity_potential
+ def __repr__(self):
+ return f"This seed has: \n -sowing rate -> {self.sowing_rate}\n" \
+ f" -ripeness group: -> {self.ripeness_group}\n" \
+ f" -productivity potential -> {self.productivity_potential}"
+
+
+class CornSeeds(Seeds):
+ def __init__(self, sowing_rate, ripeness_group, productivity_potential):
+ super().__init__(sowing_rate, ripeness_group, productivity_potential)
+ self.is_sugar = False
+ self.fao_index = None
+
+
+class SunflowerSeeds(Seeds):
+ def __init__(self, sowing_rate, ripeness_group, productivity_potential):
+ super().__init__(sowing_rate, ripeness_group, productivity_potential)
+ self.express_technology = False
+ self.oiliness = None
+
+
+class WheatSeeds(Seeds):
+ def __init__(self, sowing_rate, ripeness_group, productivity_potential):
+ super().__init__(sowing_rate, ripeness_group, productivity_potential)
+ self.winter_variety = False
+ self.quality_class = None