From a8989920a1681372161a6dec033a85184f337402 Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Fri, 10 Apr 2020 15:16:22 +0300 Subject: [PATCH 1/7] Test --- start.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 start.py diff --git a/start.py b/start.py new file mode 100644 index 0000000..7c0a935 --- /dev/null +++ b/start.py @@ -0,0 +1,2 @@ +print("Hello, world!") +print("For new Commit") \ No newline at end of file From cf816dbb01e0204ef9b2540aa1fcf44206254a06 Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Fri, 10 Apr 2020 16:43:05 +0300 Subject: [PATCH 2/7] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=20(=D0=BD=D0=B0=D0=B2=D0=B5=D1=80=D0=BD=D0=BE=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/start.py b/start.py index 7c0a935..4e79dfb 100644 --- a/start.py +++ b/start.py @@ -1,2 +1,40 @@ -print("Hello, world!") -print("For new Commit") \ No newline at end of file +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) + + 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 From 346d7de5e1f9990f965a82e500ed16a2fc238567 Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Fri, 10 Apr 2020 16:43:39 +0300 Subject: [PATCH 3/7] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=20(=D0=BD=D0=B0=D0=B2=D0=B5=D1=80=D0=BD=D0=BE=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/start.py b/start.py index 4e79dfb..0a19733 100644 --- a/start.py +++ b/start.py @@ -33,6 +33,8 @@ def task_b(a,b,x_lst): 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) From 510f1d2715248109f85890698a3491d6fec8405f Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Sat, 11 Apr 2020 10:57:38 +0300 Subject: [PATCH 4/7] =?UTF-8?q?=D0=9A=D0=BB=D0=B0=D1=81=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 classes.py 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 From d85fb08a9d82333d865f3fbcf494c594d2795c25 Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Tue, 14 Apr 2020 18:55:42 +0300 Subject: [PATCH 5/7] =?UTF-8?q?Flask=20=D0=B8=20=D1=88=D0=B0=D0=B1=D0=BB?= =?UTF-8?q?=D0=BE=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 25 +++++++++++++++++++++++ app.py | 42 +++++++++++++++++++++++++++++++++++++++ comps.py | 47 ++++++++++++++++++++++++++++++++++++++++++++ start.py | 2 +- templates/comp.html | 12 +++++++++++ templates/comps.html | 17 ++++++++++++++++ templates/new.html | 14 +++++++++++++ 7 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 app.py create mode 100644 comps.py create mode 100644 templates/comp.html create mode 100644 templates/comps.html create mode 100644 templates/new.html 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/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/start.py b/start.py index 0a19733..91c24d6 100644 --- a/start.py +++ b/start.py @@ -34,7 +34,7 @@ def task_b(a,b,x_lst): print("-------------Task A -------------") print_result(res) print("-------------Лирическое отступление--------------------") - print("Я не знала, куда писать, что x>5, поэтому просто ввела только значения которые меньше:D")\ + print("Я не знала, куда писать, вапрчто x>5, поэтому просто ввела только значения которые меньше:D")\ x_lst = [5.21, 6.28] res = task_b(a,b,x_lst) 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 From 898ef0c64506066ecfbed09c78df240bb39e59b6 Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Fri, 17 Apr 2020 16:42:35 +0300 Subject: [PATCH 6/7] =?UTF-8?q?=D0=AD=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exam.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 exam.py diff --git a/exam.py b/exam.py new file mode 100644 index 0000000..ca9b4fd --- /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) From 3c4cf1ad0e37fbec002c4b9ceaa3fed40d985dc2 Mon Sep 17 00:00:00 2001 From: Ekaterina Date: Fri, 17 Apr 2020 16:47:10 +0300 Subject: [PATCH 7/7] =?UTF-8?q?=D1=8D=D0=BA=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD,?= =?UTF-8?q?=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D0=B9=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=85=D0=BE=D1=87=D0=B5=D1=82=20=D0=B2=D1=8B=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B6=D0=B0=D1=82=D1=8C=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exam.py b/exam.py index ca9b4fd..dc34df2 100644 --- a/exam.py +++ b/exam.py @@ -16,4 +16,4 @@ def convertTemp(self, temperature, convertTO): res = con.convertTemp(64, 'F') print (res) res = con.convertTemp(300, 'F') - print (res) + print (res) \ No newline at end of file