From 6a401a35b074314f3d654287ad9f922fe1f270ca Mon Sep 17 00:00:00 2001 From: Igor Date: Sat, 18 Jul 2026 23:37:11 +0300 Subject: [PATCH] add KR --- Final control/11/legacy_shop.py | 106 +------------------------------- Final control/11/херь | 8 +++ Final control/3/Otvet.py | 58 +++++++++++++++++ Final control/4/Otvet.py | 44 +++++++++++++ Final control/4/TASK.md | 2 +- Final control/4/settings.json | 0 Final control/5/Otvet.py | 0 settings.json | 3 + 8 files changed, 116 insertions(+), 105 deletions(-) create mode 100644 Final control/11/херь create mode 100644 Final control/3/Otvet.py create mode 100644 Final control/4/settings.json create mode 100644 Final control/5/Otvet.py create mode 100644 settings.json diff --git a/Final control/11/legacy_shop.py b/Final control/11/legacy_shop.py index fa19d30..a16ff72 100644 --- a/Final control/11/legacy_shop.py +++ b/Final control/11/legacy_shop.py @@ -259,110 +259,8 @@ while True: shipping_cost = shipping_cost * 0.5 if total_price > 10000.0: shipping_cost = 0.0 - elif city.lower() == 'saintpetersburg': - shipping_cost = 300.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 12 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'novosibirsk': - shipping_cost = 500.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 20 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'ekaterinburg': - shipping_cost = 450.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 18 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'kazan': - shipping_cost = 380.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 15 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'samara': - shipping_cost = 390.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 15 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'sochi': - shipping_cost = 400.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 15 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'vladivostok': - shipping_cost = 680.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 28 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'krasnodar': - shipping_cost = 350.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 12 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'ufa': - shipping_cost = 410.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 16 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'perm': - shipping_cost = 430.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 16 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'tula': - shipping_cost = 300.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 11 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - elif city.lower() == 'kaliningrad': - shipping_cost = 480.0 - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 19 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.5 - if total_price > 10000.0: - shipping_cost = 0.0 - else: - # default calculation for other cities - if total_weight > 5.0: - shipping_cost += (total_weight - 5.0) * 25 - if total_price > 5000.0: - shipping_cost = shipping_cost * 0.8 - if total_price > 12000.0: - shipping_cost = 0.0 + def calculations_price(shipping_cost, total_weight, total_price): + discount = 0.0 diff --git a/Final control/11/херь b/Final control/11/херь new file mode 100644 index 0000000..72a90a9 --- /dev/null +++ b/Final control/11/херь @@ -0,0 +1,8 @@ + if city.lower() == 'moscow': + shipping_cost = 200.0 + if total_weight > 5.0: + shipping_cost += (total_weight - 5.0) * 10 + if total_price > 5000.0: + shipping_cost = shipping_cost * 0.5 + if total_price > 10000.0: + shipping_cost = 0.0 \ No newline at end of file diff --git a/Final control/3/Otvet.py b/Final control/3/Otvet.py new file mode 100644 index 0000000..848fdc0 --- /dev/null +++ b/Final control/3/Otvet.py @@ -0,0 +1,58 @@ +def parse_sensor_data(record): + number_data = [] + plants_data = [] + for recor in record: + if type(recor) is float: + number_data.append(recor) + if type(recor) is str: + plants_data.append(recor) + result = (number_data, plants_data) + return result + + +def calculate_statistics(dataset): + if not dataset: + return [] + num = 0 + for data in dataset: + num += data + mean = num / len(dataset) + std = ((sum((data - mean) ** 2)) / len(dataset)) ** 0,5 + statistic = {"mean": mean,"std": std} + return statistic + + +def normalize_features(features, stats): + new_data = [] + for feat in features: + fet = (feat - stats["std"]) / stats["mean"] + new_data.append(fet) + return new_data + + +def euclidean_distance(vector_a, vector_b): + summ = 0 + for i in range(len(vector_a)): + summ += (vector_a[i] - vector_b[i]) ** 2 + return summ ** 0,5 + + +def find_k_nearest(train_set, test_point, k): + distances = [] + for train_feater,train_laibel in train_set: + + + + + + + + + + + + +def majority_vote(neighbors): + val = {} + for lox in neighbors: + val[lox] = val.get(lox, 0) + \ No newline at end of file diff --git a/Final control/4/Otvet.py b/Final control/4/Otvet.py index e69de29..a80191c 100644 --- a/Final control/4/Otvet.py +++ b/Final control/4/Otvet.py @@ -0,0 +1,44 @@ +import json + + +class Config(): + def __init__(self, filename): + self.filename = filename + + def load(self): + try: + with open(self.filename, "r", encoding="utf-8") as file: + return json.load(file) + except FileNotFoundError: + return {} + + def save(self, data): + with open(self.filename, "w", encoding="utf-8") as file: + json.dump(data, file,indent=4, ensure_ascii=False) + + def get(self, key, default=None): + data = self.load() + return data.get(key, default) + + + def set(self, key, value): + data = self.load() + data[key]=value + self.save(data) + + +class Application(): + def __init__(self, config): + self.config = config + + def run(self): + username = self.config.get("username","гость") + print(f"Hello,{username}") + + def set_username(self, name): + self.config.set("username", name) + +config = Config("settings.json") +ap = Application(config) +ap.set_username("Иван") +ap.run() diff --git a/Final control/4/TASK.md b/Final control/4/TASK.md index 4d1d3d0..40610cf 100644 --- a/Final control/4/TASK.md +++ b/Final control/4/TASK.md @@ -25,7 +25,7 @@ **Тесты:** -1. Создайте `Config("settings.json")` и `Application(config)` +1. Создайте `Config("settings.json")` и ``Application(config) 2. Запустите приложение (должно вывести "Гость") 3. Установите имя через `set_username("Иван")` 4. Запустите снова (должно вывести "Иван") diff --git a/Final control/4/settings.json b/Final control/4/settings.json new file mode 100644 index 0000000..e69de29 diff --git a/Final control/5/Otvet.py b/Final control/5/Otvet.py new file mode 100644 index 0000000..e69de29 diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..edd85f6 --- /dev/null +++ b/settings.json @@ -0,0 +1,3 @@ +{ + "username": "Иван" +} \ No newline at end of file