diff --git a/.vs/Tprogramming_198_2020/v15/.suo b/.vs/Tprogramming_198_2020/v15/.suo new file mode 100644 index 0000000..66d16e6 Binary files /dev/null and b/.vs/Tprogramming_198_2020/v15/.suo differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..6b61141 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4d68506 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Используйте IntelliSense, чтобы узнать о возможных атрибутах. + // Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов. + // Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Текущий файл", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cce6b31 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "D:\\python.exe" +} \ No newline at end of file diff --git a/TV.py b/TV.py new file mode 100644 index 0000000..fb954f9 --- /dev/null +++ b/TV.py @@ -0,0 +1,54 @@ +class TV: + def __init__(self, name): + self. name = name + self.__chanel = 0 + print("Создание объекта") + + @property + def chanel(self): + return self.__chanel + + @chanel.setter + def chanel(self, chanel): + if isinstance(chanel,(int, float)) and chanel >= 0 and chanel <= 100: + self.__chanel = chanel + else: + print("Не правильно указано количество каналов") + + def increase_chanel(self): + self.__chanel = self.__chanel + 1 + + def swim(self): + print(f"я {self.name}, я показываю") + + def __str__(self): + return f"name: {self.name}, chanel: {self.__chanel}" + """ + ______________ + |.------------.| + || 88::%%## || + || 88::%%## || + || 88::%%## || + __ || 88::%%## || +|==| ||____________|| +|88| |[##] oo O [##]| +|88| |==sharp=======| +|__| |______________| + """ + +if __name__ == "__main__": + TV1 = TV("samsung") + TV1.chanel = 99 + TV1.increase_chanel() + print(TV1.name, TV1.chanel) + TV1.swim() + + TV2 = TV("ld") + TV2.chanel = 10 + TV2.increase_chanel() + print(TV2.name, TV2.chanel) + TV2.swim() + + + TV2.chanel = "Test" + + print(TV2) \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..b11d688 --- /dev/null +++ b/app.py @@ -0,0 +1,52 @@ +from flask import Flask +app = Flask(__name__) +import datetime +from flask import render_template +import tv as Tv + +collection = [] +def init(): + tv1 = TV.TV("samsung") + collection.append(tv1) + tv2 = TV.TV("LD") + collection.append(tv2) + tv3 = TV.TV("Philips") + collection.append(tv3) + + init() + +@app.route('/') +def hello_world(): + return f'Hello 1, World! {datetime.datetime.now()}' + +@app.route('/') +def test(): + user = {'username': 'Lidia'} + return render_template('index.html', title='Home', user=user) + +from flask import request + +@app.route('/params') +def params(): + print(request.args) + a = request.args.get("a", default=0, type=float) + b = request.args.get("b", default=0, type=float) + return f'Hello {a} + {b} = {a + b}' + +@app.route('/calc/', methods=['GET', 'POST']) +def calc(type_calc): + a = request.form.get("a", default=0, type=float) + b = request.form.get("b", default=0, type=float) + res = 0 + sign = "" + if type_calc == "summ": + res = a + b + sign = "+" + if type_calc == "mul": + res = a*b + sign = "x" + return render_template('calc.html', result=res, sign=sign) + +@app.route("/TV/new", methods=["GET", "POST"]) +def tv_add(): + name = request.form.get("name", default = "") \ No newline at end of file diff --git a/calc.html b/calc.html new file mode 100644 index 0000000..6a9defb --- /dev/null +++ b/calc.html @@ -0,0 +1,14 @@ + + + Calculator + + +

Calculator

+
+ + + +
+

Result = {{result}}

+ + \ No newline at end of file diff --git a/calc_test.py b/calc_test.py new file mode 100644 index 0000000..b9cf253 --- /dev/null +++ b/calc_test.py @@ -0,0 +1,31 @@ +import unittest +import start + +class CalcTests(unittest.TestCase): + a = 0.4 + b = 0.8 + + def test_positive(self): + res = start.calc(1, 1, 0) + self.assertAlmostEqual(0,res,3) + + def test_normal_b(self): + x_lst = [4.48, 3.56, 2.78, 5.28, 3.21] + res = start.task_b(self.a,self.b,x_lst) + self.assertEqual(5, len(res)) + + def test_zero_lengt(self): + x_lst = [] + res = start.task_b(self.a,self.b,x_lst) + self.assertEqual(0, len(res)) + + def test_normal_a(self): + res = start.task_a(self.a, self.b, 0.77, 1.77, 0.2) + self.assertEqual(6, len(res)) + + def test_zero_a(self): + res = start.task_a(self.a, self.b, 4.77, 1.77, 0.2) + self.assertEqual(0, len(res)) + +if __name__ == '__main__': + unittest.main() diff --git a/exam.py b/exam.py new file mode 100644 index 0000000..b7bca3b --- /dev/null +++ b/exam.py @@ -0,0 +1,6 @@ +print("Рецепт бутерброда:") +ingredients = ['слизни', 'пиявки', 'катышки из пупка гориллы', 'брови гусеницы', 'пальцы многоножки'] +length = len(ingredients) +for i in range(length): + print(str(i+1), ") ", ingredients[i], sep="", end=";\n") + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..3c3225f --- /dev/null +++ b/index.html @@ -0,0 +1,9 @@ + + + Calculator + + +

Hello, {{ user.username }}!

+

Hello again

+ + diff --git a/pip b/pip new file mode 100644 index 0000000..5499398 --- /dev/null +++ b/pip @@ -0,0 +1 @@ +$ pip install flask diff --git a/start.py b/start.py new file mode 100644 index 0000000..c8f0370 --- /dev/null +++ b/start.py @@ -0,0 +1,45 @@ +print("Hello word!") +import math +a = 0.4 +b = 0.8 +x = 3.2 + +def calc(a, b, x): + y = ((a**b-b**x)/(math.log1p(a/b)))*((a*b))**(1/3) + 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 = 0.4 + b = 0.8 + + res = task_a(a, b, 0.77, 1.77, 0.2) + print("-------------Task A -------------") + print_result(res) + + x_lst = [4.48, 3.56, 2.78, 5.28, 3.21] + res = task_b(a,b,x_lst) + print("-------------Task B -------------") + + print_result(res) diff --git a/test.py b/test.py new file mode 100644 index 0000000..4bd64c7 --- /dev/null +++ b/test.py @@ -0,0 +1,31 @@ +import unittest + + +def summ(a,b): + return a + b + +class CalcTests(unittest.TestCase): + + def test_positive(self): + res = summ(2,3) + self.assertEqual(5,res) + + def test_zero(self): + res = summ(0,0) + self.assertEqual(0,res) + + def test_one_negative(self): + res = summ(-2,3) + self.assertEqual(1,res) + + def test_both_negative(self): + res = summ(-2,-4) + self.assertEqual(-6,res) + + def test_one_negative_zero_res(self): + res = summ(-2,2) + self.assertEqual(0,res) + + +if __name__ == '__main__': + unittest.main() diff --git a/test_TV.py b/test_TV.py new file mode 100644 index 0000000..8af4a45 --- /dev/null +++ b/test_TV.py @@ -0,0 +1,40 @@ +import unittest +import TV + +class ClassTests(unittest.TestCase): + def test_empty(self): + self.assertTrue(True) + + def test_creation(self): + tst = TV.TV("TV") + self.assertEqual("TV", tst.name) + + def test_chanel_change(self): + tst = TV.TV("TV") + self.assertEqual("TV", tst.name) + tst.chanel = 5 + self.assertEqual(5, tst.chanel) + + def test_wrong_chanel_change(self): + tst = TV.TV("TV") + self.assertEqual("TV", tst.name) + tst.chanel = -5 + self.assertEqual(0, tst.chanel) + + def test_wrong_type_chanel_change(self): + tst = TV.TV("TV") + self.assertEqual("TV", tst.name) + tst.chanel = "10 chanels" + self.assertEqual(0, tst.chanel) + + def test_wrong_name_change(self): + tst = TV.TV("TV") + self.assertEqual("TV", tst.name) + tst.name = "ld" + self.assertEqual("ld", tst.name) + + +if __name__ =='__main__': + unittest.main() + +