Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,29 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
},
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py",
"FLASK_ENV": "development"
},
"args": [
"run",
"--no-debugger"
],
"jinja": true,
"justMyCode": true
}
]
}
16 changes: 16 additions & 0 deletions EXZAMEN/exam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def revers_word(s: str) -> str:
l = s.split(' ')
l.reverse()
return ' '.join(l)


if __name__ == '__main__':

print('0 words')
print(revers_word(''))

print('1 words')
print(revers_word('one'))

print('5 words')
print(revers_word('one two tree four five'))
28 changes: 28 additions & 0 deletions EXZAMEN/exam_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from unittest import TestCase
import exam

class ReversTest(TestCase):

def test_zero_words(self):
self.assertEqual('', exam.revers_word(''))

def test_one_words(self):
self.assertEqual('one', exam.revers_word('one'))

def test_five_words(self):
self.assertEqual('five four tree two one', exam.revers_word('one two tree four five'))

def test_five_words_with_dot(self):
self.assertEqual('five. four tree two One', exam.revers_word('One two tree four five.'))

def test_five_words_sep_comma(self):
self.assertEqual('five four, tree, two, one,', exam.revers_word('one, two, tree, four, five'))

def test_five_words_sep_dash(self):
self.assertEqual('one-two-tree-four-five', exam.revers_word('one-two-tree-four-five'))

def test_ten_words_two_line(self):
self.assertEqual('ten nine eight seven five\nsix four tree two one', exam.revers_word('one two tree four five\nsix seven eight nine ten'))

def test_digit(self):
self.assertEqual('5 4 3 2 1', exam.revers_word('1 2 3 4 5'))
36 changes: 36 additions & 0 deletions Lab_1/function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import math


def f(a:float, b:float, x:float) -> float:

chisl = math.log((x**2) - 1)
znam = math.log(a * x**2 - b, 5)
return chisl / znam


def task_a(a:float, b:float, xn:float, xk:float, dx:float) -> list:

y = []
while xn < xk:
y.append(f(a, b, xn))
xn += dx
return y


def task_b(a:float, b:float, x:enumerate) -> list:

y = []
for i in x:
y.append(f(a, b, i))
return y


if __name__ == '__main__':

# print(f(1.1, 0.09, 0))

print('Task A')
print(task_a(1.1, 0.09, 1.2, 2.2, 0.2))

print('Task B')
print(task_b(1.1, 0.09, (1.21, 1.76, 2.53, 3.48, 4.52)))
28 changes: 28 additions & 0 deletions Lab_1/function_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from unittest import TestCase
import Lab_1.function as function

class TestFunction(TestCase):

def test_f(self):
res = function.f(1.1, 0.09, 1.2)
self.assertAlmostEqual(-3.29, res, 2)

def test_task_a_ok(self):
y = function.task_a(1.1, 0.09, 1.2, 2.2, 0.2)
self.assertAlmostEqual(6, len(y))

def test_task_b_ok(self):
y = function.task_b(1.1, 0.09, (1.21, 1.76, 2.53, 3.48, 4.52))
self.assertAlmostEqual(5, len(y))

def test_task_a(self):
y = function.task_a(1.1, 0.09, 1.2, 2.2, 0.2)
right_y = [-3.291, -0.0905, 0.714, 1.042, 1.210, 1.308]
for i in range(5):
self.assertAlmostEqual(y[i], right_y[i], 3)

def test_task_b(self):
y = function.task_b(1.1, 0.09, (1.21, 1.76, 2.53, 3.48, 4.52))
right_y = [-2.948, 0.994, 1.4, 1.501, 1.536]
for i in range(5):
self.assertAlmostEqual(right_y[i], y[i], 3)
36 changes: 36 additions & 0 deletions Loktev_198/loktev/function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import math


def f(a:float, b:float, x:float) -> float:

chisl = b**3 + math.sin(a*x)**2
znam = math.acos(x*(b**x)) + math.exp(-x/2)
return chisl / znam


def task_a(a:float, b:float, xn:float, xk:float, dx:float) -> list:

y = []
while xn < xk:
y.append(f(a, b, xn))
xn += dx
return y


def task_b(a:float, b:float, x:enumerate) -> list:

y = []
for i in x:
y.append(f(a, b, i))
return y


if __name__ == '__main__':

print(f(1.2, 0.48, 0))

print('Task A')
print(task_a(1.2, 0.48, 0.7, 2.2, 0.3))

print('Task B')
print(task_b(1.2, 0.48, (0.25, 0.36, 0.56, 0.94, 1.28)))
32 changes: 32 additions & 0 deletions Loktev_198/loktev/function_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from unittest import TestCase
import function as function

class TestFunction(TestCase):

def test_f(self):
res = function.f(1.2, 0.48, 0.7)
self.assertAlmostEqual(0.36, res, 2)

def test_f_zero(self):
res = function.f(1.2, 0.48, 0)
self.assertAlmostEqual(0.043, res, 3)

def test_task_a_ok(self):
y = function.task_a(1.2, 0.48, 0.7, 2.2, 0.3)
self.assertAlmostEqual(5, len(y))

def test_task_b_ok(self):
y = function.task_b(1.2, 0.48, (0.25, 0.36, 0.56, 0.94, 1.28))
self.assertAlmostEqual(5, len(y))

def test_task_a(self):
y = function.task_a(1.2, 0.48, 0.7, 2.2, 0.3)
right_y = [0.361, 0.584, 0.708, 0.661, 0.468]
for i in range(5):
self.assertAlmostEqual(y[i], right_y[i], 3)

def test_task_b(self):
y = function.task_b(1.2, 0.48, (0.25, 0.36, 0.56, 0.94, 1.28))
right_y = [0.09, 0.13, 0.26, 0.54, 0.7]
for i in range(5):
self.assertAlmostEqual(right_y[i], y[i], 2)
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
flask = "*"

[dev-packages]
mypy = "*"
Expand Down
Loading