diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e9b4ac4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Flask", + "type": "python", + "request": "launch", + "module": "flask", + "env": { + "FLASK_APP": "app.py", + "FLASK_ENV": "development", + "FLASK_DEBUG": "0" + }, + "args": [ + "run", + "--no-debugger", + "--no-reload" + ], + "jinja": true + } + ] +} \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..c5748ce --- /dev/null +++ b/app.py @@ -0,0 +1,42 @@ +from flask import Flask +app = Flask(__name__) +import datetime +from flask import render_template +import comp +import comp as Comp + +collection = [] +def init(): + comp1 = comp.Comp("Laptop") + collection.append(comp1) + comp2 = comp.Comp("PC") + collection.append(comp2) + comp3 = comp.Comp("Compukter") + collection.append(comp3) + +from flask import request + +@app.route("/comps/new", methods=["GET", "POST"]) +def comps_add(): + name = request.form.get("name", default="", type=str) + age = request.form.get("hdd", default="0", type=float) + if name: + comp1 = comp.Comp(name) + comp1.hdd = hdd + collection.append(comp1) + return render_template("new.html") + +@app.route('/comps/') +def comp(name): + item = None + for el in collection: + if name == el.name: + item = el + break + + return render_template("comp.html", item=item) + +@app.route('/comps') +def comps(): + return render_template ("comps.html", collection = collection) + diff --git a/classes.py b/classes.py new file mode 100644 index 0000000..34c8ac3 --- /dev/null +++ b/classes.py @@ -0,0 +1,47 @@ +class Comp: + + def __init__(self, name): + self.name = name + self.__hdd = 0 + print("Создание объекта") + + @property + def hdd(self): + return self.__hdd + + @hdd.setter + def hdd(self, hdd): + if isinstance(hdd,(int, float)) and hdd >= 32 and hdd <= 100: + self.__hdd = hdd + else: + print("Не правильно указан объем жесткого диска") + + def increase_hdd(self): + self.hdd = self.hdd + 1 + + def __str__(self): + return f"name: {self.name}, hdd: {self.hdd}" + """ + _______ + |.-----.| + ||x . x|| + ||_.-._|| + `--)-(--` + __[=== o]___ + |:::::::::::| + `-=========-`() +""" +if __name__ == "__main__": + comp1 = Comp("Laptop") + comp1.hdd = 42 + comp1.increase_hdd() + print(comp1.name, comp1.hdd) + + comp2 = Comp("PC") + comp2.hdd = 99 + comp2.increase_hdd() + print(comp2.name, comp2.hdd) + + comp2.hdd = 101 + comp2.hdd = "Test" + + print(comp2) \ No newline at end of file diff --git a/comps.py b/comps.py new file mode 100644 index 0000000..34c8ac3 --- /dev/null +++ b/comps.py @@ -0,0 +1,47 @@ +class Comp: + + def __init__(self, name): + self.name = name + self.__hdd = 0 + print("Создание объекта") + + @property + def hdd(self): + return self.__hdd + + @hdd.setter + def hdd(self, hdd): + if isinstance(hdd,(int, float)) and hdd >= 32 and hdd <= 100: + self.__hdd = hdd + else: + print("Не правильно указан объем жесткого диска") + + def increase_hdd(self): + self.hdd = self.hdd + 1 + + def __str__(self): + return f"name: {self.name}, hdd: {self.hdd}" + """ + _______ + |.-----.| + ||x . x|| + ||_.-._|| + `--)-(--` + __[=== o]___ + |:::::::::::| + `-=========-`() +""" +if __name__ == "__main__": + comp1 = Comp("Laptop") + comp1.hdd = 42 + comp1.increase_hdd() + print(comp1.name, comp1.hdd) + + comp2 = Comp("PC") + comp2.hdd = 99 + comp2.increase_hdd() + print(comp2.name, comp2.hdd) + + comp2.hdd = 101 + comp2.hdd = "Test" + + print(comp2) \ No newline at end of file diff --git a/exam.py b/exam.py new file mode 100644 index 0000000..dc34df2 --- /dev/null +++ b/exam.py @@ -0,0 +1,19 @@ +class TemperatureConverter: + def convertTemp(self, temperature, convertTO): + if (convertTO == "F"): + temperature = (temperature - 32) * (5/9) + else: + temperature = temperature * (9/5) + 32 + + return temperature + +if __name__ == "__main__": + con = TemperatureConverter() + res = con.convertTemp(7, 'C') + print (f"7 * C -> {res} * F") + res = con.convertTemp(43, 'C') + print (f"43 * C -> {res} * F") + res = con.convertTemp(64, 'F') + print (res) + res = con.convertTemp(300, 'F') + print (res) \ No newline at end of file diff --git a/start.py b/start.py new file mode 100644 index 0000000..91c24d6 --- /dev/null +++ b/start.py @@ -0,0 +1,42 @@ +import math + +def calc(a, b, x): + y = math.log10(a**2+x)**2/(a+x)**2 + return y + +def task_a(a,b,xn,xk,dx): + x = xn + res = [] + while x <= xk: + y = calc(a, b, x) + res.append((x,y)) + x = x + dx + return res + +def print_result(result): + for item in result: + x,y = item + print(f"x={x} y={y}") + +def task_b(a,b,x_lst): + res = [] + for x in x_lst: + y = calc(a, b, x) + res.append((x,y)) + return res + + +if __name__ == "__main__": + a = -2.5 + b = 3.4 + + res = task_a(a,b,3.5,6.5,0.6) + print("-------------Task A -------------") + print_result(res) + print("-------------Лирическое отступление--------------------") + print("Я не знала, куда писать, вапрчто x>5, поэтому просто ввела только значения которые меньше:D")\ + + x_lst = [5.21, 6.28] + res = task_b(a,b,x_lst) + print("-------------Task B -------------") + print_result(res) \ No newline at end of file diff --git a/templates/comp.html b/templates/comp.html new file mode 100644 index 0000000..58c6735 --- /dev/null +++ b/templates/comp.html @@ -0,0 +1,12 @@ + + + + Comps + + + +

Компьютер

+

Имя: {{item.name}} объем жесткого диска {{item.hdd}}

+ + + \ No newline at end of file diff --git a/templates/comps.html b/templates/comps.html new file mode 100644 index 0000000..ce536d8 --- /dev/null +++ b/templates/comps.html @@ -0,0 +1,17 @@ + + + + {{ title }} - Comps + + + +

Список компьютеров

+ Добавить + + + + \ No newline at end of file diff --git a/templates/new.html b/templates/new.html new file mode 100644 index 0000000..71017b1 --- /dev/null +++ b/templates/new.html @@ -0,0 +1,14 @@ + + + Comps + + +

Создать компьютер

+
+

Имя

+

Объем жесткого диска

+ +
+ + + \ No newline at end of file