Исправлены главы
@@ -303,7 +303,7 @@
|
||||
"source": [
|
||||
"a = 4\n",
|
||||
"b = 3\n",
|
||||
"a ** b"
|
||||
"a**b"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -319,7 +319,7 @@
|
||||
"\n",
|
||||
"Для создания комплексного числа можно использовать функцию `complex(a, b)`, в\n",
|
||||
"которую, в качестве первого аргумента, передается действительная часть, в качестве\n",
|
||||
"второго – мнимая. Либо записать число в виде `a + bj`.\n",
|
||||
"второго – мнимая. Либо записать число в виде `a+bj`.\n",
|
||||
"\n",
|
||||
"Рассмотрим несколько примеров.\n",
|
||||
"\n",
|
||||
@@ -334,7 +334,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"z = 1 + 2j\n",
|
||||
"z = 1+2j\n",
|
||||
"print(z)"
|
||||
]
|
||||
},
|
||||
@@ -346,8 +346,8 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = complex ( 3 , 2 )\n",
|
||||
"print (x)"
|
||||
"x = complex(3, 2)\n",
|
||||
"print(x)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -366,7 +366,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x + z"
|
||||
"x+z"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -377,7 +377,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x - z"
|
||||
"x-z"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -388,7 +388,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x * z"
|
||||
"x*z"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -399,7 +399,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x / z"
|
||||
"x/z"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -410,7 +410,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x ** z"
|
||||
"x**z"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -421,7 +421,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x ** 3"
|
||||
"x**3"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -439,7 +439,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = 3 + 2j\n",
|
||||
"x = 3+2j\n",
|
||||
"x.real"
|
||||
]
|
||||
},
|
||||
@@ -687,7 +687,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"math.ceil( 3.2 )"
|
||||
"math.ceil(3.2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -747,7 +747,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"math.floor( 3.2 )"
|
||||
"math.floor(3.2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -766,7 +766,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"math.exp( 3 )"
|
||||
"math.exp(3)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -805,7 +805,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"math.log10( 1000 )"
|
||||
"math.log10(1000)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
1235
datatype.ipynb
BIN
fig-datatype/strings_1.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
fig-datatype/strings_2.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
fig-datatype/strings_3.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
fig-datatype/strings_4.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
fig-intro/jupyter_1.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
fig-intro/jupyter_2.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
fig-intro/jupyter_3.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
fig-intro/jupyter_4.png
Normal file
|
After Width: | Height: | Size: 328 KiB |
BIN
fig-intro/jupyter_5.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
fig-intro/jupyter_6.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
fig-intro/jupyter_6.png~
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
fig-intro/jupyter_7.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
fig-intro/jupyter_7.png~
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
1797
intro.ipynb
49
src-datatype/quadratic.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import cmath
|
||||
import math
|
||||
import sys
|
||||
|
||||
# Start get_float
|
||||
def get_float(msg, allow_zero):
|
||||
x = None
|
||||
while x is None:
|
||||
try:
|
||||
x = float(input(msg))
|
||||
if not allow_zero and abs(x) < sys.float_info.epsilon:
|
||||
print("zero is not allowed")
|
||||
x = None
|
||||
|
||||
except ValueError as err:
|
||||
print(err)
|
||||
return x
|
||||
# End get_float
|
||||
|
||||
# Start 1st block
|
||||
print("ax\N{SUPERSCRIPT TWO} + bx + c = 0")
|
||||
a = get_float("enter a: ", False)
|
||||
b = get_float("enter b: ", False)
|
||||
c = get_float("enter c: ", False)
|
||||
# End 1st block
|
||||
|
||||
# Start 2d block
|
||||
x1 = None
|
||||
x2 = None
|
||||
discriminant = (b ** 2) - (4 * a * c)
|
||||
if discriminant == 0:
|
||||
x1 = -(b / (2 * a))
|
||||
else:
|
||||
if discriminant > 0:
|
||||
root = math.sqrt(discriminant)
|
||||
else: # discriminant < 0
|
||||
root = cmath.sqrt(discriminant)
|
||||
x1 = (-b + root) / (2 * a)
|
||||
x2 = (-b - root) / (2 * a)
|
||||
# End 2d block
|
||||
|
||||
# Start 3d block
|
||||
equation = ("{0}x\N{SUPERSCRIPT TWO} + {1}x + {2} = 0"
|
||||
" \N{RIGHTWARDS ARROW} x = {3}").format(a, b, c, x1)
|
||||
if x2 is not None:
|
||||
equation += " or x = {0}".format(x2)
|
||||
print(equation)
|
||||
# End 3d block
|
||||
6
src-intro/.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
49
src-intro/Untitled.ipynb
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Заголовок 1 уровня\n",
|
||||
"## Заголовок 2 уровня\n",
|
||||
"### Заголовок 3 уровня"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"> Этот текст печатается со сдвигом\n",
|
||||
"> по отношению к основному тексту."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"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.8.1"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
46
src-intro/Untitled.ipynb~
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Заголовок 1 уровня\n",
|
||||
"## Заголовок 2 уровня\n",
|
||||
"### Заголовок 3 уровня"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"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.8.1"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
14
src-intro/fib.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
def fib(n):
|
||||
"""
|
||||
Возвращает список первых n чисел Фибоначи
|
||||
"""
|
||||
f0, f1 = 0, 1
|
||||
f = [1]*n
|
||||
for i in range(1, n):
|
||||
f[i] = f0 + f1
|
||||
f0, f1 = f1, f[i]
|
||||
|
||||
return f
|
||||
|
||||
print(fib(10))
|
||||
1
src-intro/hello.py
Normal file
@@ -0,0 +1 @@
|
||||
print("Hello from Python!")
|
||||
6
src-intro/walkers.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
|
||||
def random_walker_max_distance(M, N):
|
||||
trajectories = [np.random.randn(M).cumsum() for _ in range(N)]
|
||||
return np.max(np.abs(trajectories))
|
||||