neznayhz/numpy.ipynb
2026-04-29 22:47:04 +03:00

110 lines
2.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "3af2cc9d-8792-4968-972a-cdfed0d85dce",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Моя матрица 2x2:\n",
"[[ 5 7]\n",
" [ 9 10]]\n",
"\n",
"Тестирую linspace:\n",
"Массив от 0 до 10 с 5 элементами:\n",
"[ 0. 2.5 5. 7.5 10. ]\n",
"\n",
"Случайные числа из randn:\n",
"[ 0.04269067 0.9476501 -0.05281896]\n",
"\n",
"Умножаю матрицу на саму себя через dot:\n",
"Результат:\n",
"[[ 88 105]\n",
" [135 163]]\n",
"\n",
"Сумма всех элементов матрицы:\n",
"31\n",
"Среднее арифметическое:\n",
"7.75\n"
]
},
{
"data": {
"text/plain": [
"array([[ 5, 7],\n",
" [ 9, 10]])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"matrix = np.array([[5, 7], [9, 10]])\n",
"\n",
"print(\"Моя матрица 2x2:\")\n",
"print(matrix)\n",
"\n",
"print(\"\\nТестирую linspace:\")\n",
"arr = np.linspace(0, 10, 5)\n",
"print(\"Массив от 0 до 10 с 5 элементами:\")\n",
"print(arr)\n",
"\n",
"print(\"\\nСлучайные числа из randn:\")\n",
"random_arr = np.random.randn(3)\n",
"print(random_arr)\n",
"\n",
"print(\"\\nУмножаю матрицу на саму себя через dot:\")\n",
"result = np.dot(matrix, matrix)\n",
"print(\"Результат:\")\n",
"print(result)\n",
"\n",
"print(\"\\nСумма всех элементов матрицы:\")\n",
"summa = np.sum(matrix)\n",
"print(summa)\n",
"\n",
"print(\"Среднее арифметическое:\")\n",
"srednee = np.mean(matrix)\n",
"print(srednee)\n",
"\n",
"matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2bbf5089-c335-4e5a-8c8f-5b7858176c6d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}