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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python-envs.defaultEnvManager": "ms-python.python:system",
"python-envs.pythonProjects": []
}
3 changes: 0 additions & 3 deletions README.md

This file was deleted.

Binary file added __pycache__/lec_numpy.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/numpy.cpython-312.pyc
Binary file not shown.
12 changes: 12 additions & 0 deletions lec_generators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np

a = range(0, 5, 1)
print(a)

# a = range(0, 10, 0.1)

b = np.arange(0, 5, 0.1) #хранит массив с данными. как рандж включает старт, не включает стоп
print(b)

d = np.linspace(0, 5, 10) #включает старт, включает стоп, хранит массивы
print(d)
11 changes: 11 additions & 0 deletions lec_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Модуль lec_import.py

# Инструкция, целиком загружающая модуль
import lec_my_module

print(lec_my_module.a) #точка - это оператор, предоставляющий доступ к атрибутам объектов

b = lec_my_module.b * 3
print(b)

print(lec_my_module.c[2])
8 changes: 8 additions & 0 deletions lec_import_as.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import lec_my_module as mm

print(mm.a)

b = mm.b * 3
print(b)

print(mm.c[2] + b + mm.c[0])
9 changes: 9 additions & 0 deletions lec_import_false.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lec_my_module import b
from lec_import_as import b

print(b)

import lec_my_module as mm
import lec_import_as as l3

print(mm.b + l3.b)
9 changes: 9 additions & 0 deletions lec_import_from.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Копирование указанных атрибутов модуля
from lec_my_module import a, b

print(a * b)

# Копирование ВСЕХ атрибутов модуля
from lec_my_module import *

print(c[2] * c[1])
9 changes: 9 additions & 0 deletions lec_import_from_as.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lec_my_module import earth_mass as em
from lec_my_module import gravity_constant as G
from lec_my_module import sigma_steff_bolc as sigma

g = 500 * G / 10 ** 2
print(g)

x = em * G * sigma
print(x)
13 changes: 13 additions & 0 deletions lec_math.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import math

a = math.sin(3 * math.pi / 5)
print(a)

b = math.sqrt(3)
print(b)

c = math.log10(42)
print(c)

d = math.asin(math.tan(math.pi / 4)) * 180 / math.pi
print(d)
11 changes: 11 additions & 0 deletions lec_my_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Модуль lec_my_module.py

# Атрибуты модуля
a = 3
b = 'Good'
c = ['Bad', 4, 'Petya molodec']

earth_mass = 5.97 * 10 ** 30
sigma_steff_bolc = 5.67 * 10 ** (-8)
gravity_constant = 6.67 * 10 ** (-11)

16 changes: 16 additions & 0 deletions lec_np.array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import lec_numpy as np

a = [1, 2, 4]

b = np.array(a) # Создание массива из списка

print(type(a))
print(type(b))

print(b * b)
print(b / b)
print(b - b)

# print(a - a)

print(b[-1]) # Вызов последнего элеманта массива
17 changes: 17 additions & 0 deletions lec_np.zeros_np.ones_np.ndarray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import lec_numpy as np

a = np.zeros((2, 3))
print(a)

a[0, 2] = 5
print(a)

b = np.ones((3, 2))
print(b)

c = np.ndarray((3, 3))
print(c)

print(type(a))
print(type(b))
print(type(c))
43 changes: 43 additions & 0 deletions lec_numpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import numpy as np

#3*x+2*y=7
#5x-3y=-1
#Ax = B => x = A^(-1)*B

A = np.array([[3,2],[5,-3]], dtype='float')
B = np.array([[7],[-1]], dtype='float')

print(A)
print(B)

A_inv = np.linalg.inv(A) #A-1
print(A_inv)

print(A @ A_inv)

x = A_inv @ B
print(x)

"""
3x+5y+4z=23
-5x+2y-4z=11
-2x-3y-5z=-5
"""

A = np.array([[3,5,4],[-5,2,-4],[-2,-3,-5]], dtype='float')
B = np.array([[23],[11],[-5]], dtype='float')
print(A)
print(B)

A_inv = np.linalg.inv(A) #A-1
print(A_inv)
print(A @ A_inv)
x = A_inv @ B
print(x)

print('тоже самое при поомщи метода solve')

print(np.linalg.solve(A,B))

print(A@x)
print(B)
17 changes: 17 additions & 0 deletions lec_slice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import numpy as np

a = [1, 5, 3, 6]
slice = a[0:2:1] #старт:стоп:step
print(slice)

slice = a[3:0:-1]
print(slice)

slice = a[::-1]
print(slice)

b = np.array([a, np.array(a) * 3])
print(b)

slice = b[::, 1]
print(slice)
12 changes: 12 additions & 0 deletions lec_task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np

a = [[2,3,1,4,5,6,7],[8,1,3,2,2,6,8],[1,4,3,1,0,2,5],[4,5,0,1,3,2,1],[8,7,9,1,0,2,3]]


slice1 = a[0:3:,0:4:] #старт:стоп:step
slice2 = a[1:3:,3:6:]
slice3 = a[0:4:,6::]
slice4 = a[5::,0:2:]
slice5 = a[4::,2:4:]
slice6 = a[3:5:,5::]
print(slice1)
51 changes: 51 additions & 0 deletions lec_task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import numpy as np
import time
g=9.8
t=0

x0=0
y0=0
vox=6
voy=7

a=[]
while t in range(0,5):
t+=1
x=x0+vox*t
y=y0+voy*t-((g*t**2)/2)
b = [x,round(y,1),t]
#print(b)
a.append(b)
print(a)

v=5
alpha=np.pi/180*45
vx_0=v*np.cos(alpha)
vy_0=v*np.sin(alpha)

timer = time.time()
coords = []
for t in np.arange(0,5,0.00001):
x=x0+vx_0*t
y=y0+vy_0*t-((g*t**2)/2)
coords=np.array(coords)
print(coords)
print(time.time()-timer)

timer = time.time()
step=0.00001
t=np.arange(0,5,step)
x=x0+vx_0*t
y=y0+vy_0*t-((g*t**2)/2)
coords = np.zeros((len(t),3))
coords[:,0]=t
coords[:,1]=x
coords[:,2]=y
print(coords)
print(time.time()-timer)


timer = time.time()