diff --git a/__pycache__/constants.cpython-312.pyc b/__pycache__/constants.cpython-312.pyc new file mode 100644 index 000000000..4991ed3a1 Binary files /dev/null and b/__pycache__/constants.cpython-312.pyc differ diff --git a/__pycache__/lec_create_func.cpython-312.pyc b/__pycache__/lec_create_func.cpython-312.pyc new file mode 100644 index 000000000..1aa7f1a37 Binary files /dev/null and b/__pycache__/lec_create_func.cpython-312.pyc differ diff --git a/constants.py b/constants.py new file mode 100644 index 000000000..98b182e30 --- /dev/null +++ b/constants.py @@ -0,0 +1,11 @@ +gravitational_constant = 6,67 * 10 ** -11 +speed_of_light = 3 * 10 ** 8 +avogadro_constant = 6.02214076 * 10 ** 23 +planck_constant = 6.62607015 * 10 ** 34 +first_radiation_constant = 3.741771852 * 10 ** -16 +elementary_charge = 1.602176634 * 10 ** -19 +boltzmann_constant = 1.380649 * 10 ** -23 +electron_mass = 9.1093837139 * 10 ** -31 +conductance_quantum = 7.748091729 * 10 ** -5 +molar_planck_constant = 3.9903127128934314 * 10 ** -10 +g = 9.8 \ No newline at end of file diff --git a/lec_args.py b/lec_args.py new file mode 100644 index 000000000..a6a566afb --- /dev/null +++ b/lec_args.py @@ -0,0 +1,8 @@ +def my_func(a, b): + x = 3 * a - b + return x + +tmp = my_func() + + + \ No newline at end of file diff --git a/lec_call_func.py b/lec_call_func.py new file mode 100644 index 000000000..df5d794f1 --- /dev/null +++ b/lec_call_func.py @@ -0,0 +1,9 @@ +from lec_create_func import mult_func +from lec_create_func import print_func +tmp = mult_func(4) +print(tmp) +print(mult_func(10)) +print(mult_func('Good ')) + +print_func('hello') +print_func(mult_func('50')) \ No newline at end of file diff --git a/lec_create_func.py b/lec_create_func.py new file mode 100644 index 000000000..95810a162 --- /dev/null +++ b/lec_create_func.py @@ -0,0 +1,6 @@ +def mult_func(a): + x = a * 3 + return x + +def print_func(a): + print(f'Мой принт с юлэкджеком {a}') \ No newline at end of file diff --git a/lec_data_type.py b/lec_data_type.py new file mode 100644 index 000000000..112e1853c --- /dev/null +++ b/lec_data_type.py @@ -0,0 +1,44 @@ +def changer(a , b): + a = 2 + b[0] = 'Good' + +x = 10 +L = [1, 2] + +changer(x, L) +print(x) +print(L) + +L = [1, 2] +changer(x, L[:]) +# complex +x = 3 +y = 4 + +z = complex(x,y) +print(z) + +w = complex(y, x) +print(z + w) +# str +s = 'hello' +print(s[0]) + +#s[0] = 'p' +#print(s) +#tuple +t = (1,4,9) +print(t) +print(t[0]) +#t[0] = 3 +#list +l = [1,4,9] +print(l) +print(l[0]) +l[0] = 3 +print(l) +# dict +d = {'a1':4, 4:'a1', 'str':'Hello'} +print(d['a1']) +print(d['str']) +d['str'] = 'Good' \ No newline at end of file diff --git a/lec_scop.py b/lec_scop.py new file mode 100644 index 000000000..53b6f5d37 --- /dev/null +++ b/lec_scop.py @@ -0,0 +1,12 @@ +x0 = 10 # глобальная область видимости +def move(t): + x = x0 * t # + return x # локальная область видимости +print(move(10)) +#print(x) +a = 'Good' +def my_func(): + a = 'Bad' + print(a) +my_func() +print(a) \ No newline at end of file diff --git a/task1.py b/task1.py new file mode 100644 index 000000000..240c4095a --- /dev/null +++ b/task1.py @@ -0,0 +1,9 @@ +def arithmetic_mean(arr): + x = 0 + for i in range(len(arr)): + x += arr[i] + return x / len(arr) + +array = [1, 2, 3, 4, 5] + +print(arithmetic_mean(array)) \ No newline at end of file diff --git a/task2.py b/task2.py new file mode 100644 index 000000000..40f5aadde --- /dev/null +++ b/task2.py @@ -0,0 +1,7 @@ +import numpy as np + +def multiply_elements(arr): + return np.prod(arr) + +array = np.array([1, 2, 3, 4, 5]) +print(multiply_elements(array)) diff --git a/task3.py b/task3.py new file mode 100644 index 000000000..8cae2d769 --- /dev/null +++ b/task3.py @@ -0,0 +1,16 @@ +from constants import g + +def mech_energy(mass, height, speed): + + p_energy = mass * g * height + + k_energy = 0.5 * mass * speed**2 + + energy = p_energy + k_energy + return energy + +mass = int(input('Введите массу: ')) +height = int(input('Введите высоту: ')) +speed = int(input('Введите скорость: ')) + +print(mech_energy(mass, height, speed)) \ No newline at end of file diff --git a/task4.py b/task4.py new file mode 100644 index 000000000..3d6d92e12 --- /dev/null +++ b/task4.py @@ -0,0 +1,15 @@ +import numpy as np + +def values(a, b, N): + + x = np.linspace(a, b, N) + + y = x ** 2 + + return y + + +a = int(input('Введите первый промежуток')) +b = int(input('Введите второй промежуток')) +N = int(input('Введите число точек')) +print(values(a, b, N)) \ No newline at end of file diff --git a/task5.py b/task5.py new file mode 100644 index 000000000..f0a75386c --- /dev/null +++ b/task5.py @@ -0,0 +1,25 @@ +import numpy as np + +def calculate_area(shape): + if shape == 'круг': + radius = int(input("Введите радиус круга: ")) + area = np.pi * radius ** 2 + return area + elif shape == 'прямоугольник': + length = int(input("Введите длину прямоугольника: ")) + width = int(input("Введите ширину прямоугольника: ")) + area = length * width + return area + elif shape == 'треугольник': + base = int(input("Введите основание треугольника: ")) + height = int(input("Введите высоту треугольника: ")) + area = 0.5 * base * height + return area + else: + return "Некорректная фигура!" + + +user_shape = input("Введите фигуру (круг, прямоугольник, треугольник): ") +area = calculate_area(user_shape) + +print(f"Площадь {user_shape} составляет: {area}") \ No newline at end of file