Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added name and surname #18

Open
wants to merge 9 commits into
base: Antipova_Julija
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

# Pyre type checker
.pyre/
settings.json
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// 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: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
15 changes: 15 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"

[packages]
matplotlib = "*"
mypy = "*"
numpy = "==1.19.3"

[requires]
python_version = "3.9"
354 changes: 354 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Tprogramming_184_2020
# Tprogramming_184_2020

## Antipova Juliya
21 changes: 21 additions & 0 deletions demo_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
a = "5"
try:
b = int(a)
print(b+1)
raise ZeroDivisionError()
except ValueError as err:
print(f"Value error {err}")
except Exception as err:
print(f"Common error {err}")


print("Normal continue")

def some_f(lst: tuple):
lst.append(5)

c = [1,2,3,4]
print(c)
some_f(c)
print(c)

62 changes: 62 additions & 0 deletions hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import numpy as np
import matplotlib.pyplot as plt
# import math

def calc(a, b, x):
numerator = np.log((b**2 - x**2) ,a)
denomerator = abs((x**2 - a**2))**(1/3.0)
y = numerator/denomerator
return y

def calc_np(a, b, x):
numerator = np.log(b**2 - x**2)/np.log(a)
denomerator = abs((x**2 - a**2))**(1/3.0)
y = numerator/denomerator
return y

def task_a_np(a, b, xn, xk, dx):
x = np.arange(xn, xk, dx)
y = calc_np(a, b, x)
return x, y

def task_a(a, b, xn, xk, dx):
i = xn

res = []
while i <= xk:
y = calc(a, b, i)
res.append((i, y))
i += dx
return res

def task_b(a, b, x_arr):
y = []
for x in x_arr:
res = calc(a, b, x)
y.append(res)
return y

def draw(x, y):
fig = plt.plot(x, y, 'rx')
fig[0].figure.add_axes(xlabel="asdfasdf")
plt.grid()
plt.xlabel("x")
plt.ylabel("y")
plt.title("My graphics")
plt.show()

if __name__ == "__main__":
a = 2.0
b = 4.1
x = 0.77
# y = calc(a, b, x)
# print(f"x={x:.3f} y={y:.3f}")


x, y = task_a_np(a, b, 0.77, 1.77, 0.2)
draw(x, y)
# print(a_res)

# x_arr = [1.24, 1.38, 2.38, 3.21, 0.68]
# b_res = task_b(a, b, x_arr)
# print(b_res)
11 changes: 11 additions & 0 deletions hello_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest
import hello

class TestSum(unittest.TestCase):

def test_correct_calc(self):
res = hello.calc(2,4,3)
self.assertAlmostEqual(res, 1.642, places=3, msg="Should be 1.641")

if __name__ == '__main__':
unittest.main()