форкнуто от main/python-labs
Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
541 строка
20 KiB
Markdown
541 строка
20 KiB
Markdown
# Отчет по теме 4
|
|
|
|
**Антонов Дмитрий, А-03-23**
|
|
|
|
### 1.Начало работы, настройка текущего каталога
|
|
```py
|
|
Python 3.13.7 (v3.13.7:bcee1c32211, Aug 14 2025, 19:10:51) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
|
|
Enter "help" below or click "Help" above for more information.
|
|
import os
|
|
os.chdir('//Users//dmitrijantonov//Desktop//POAC//python-labs//TEMA4//')
|
|
os.getcwd()
|
|
'/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA4'
|
|
```
|
|
|
|
### 2. Изучаю стандартные функции в модуле builtins
|
|
#### 2.1 Функция round – округление числа с заданной точностью
|
|
```py
|
|
help(round)
|
|
Help on built-in function round in module builtins:
|
|
|
|
round(number, ndigits=None)
|
|
Round a number to a given precision in decimal digits.
|
|
|
|
The return value is an integer if ndigits is omitted or None. Otherwise
|
|
the return value has the same type as the number. ndigits may be negative.
|
|
|
|
round(123.456,1)
|
|
123.5
|
|
round(123.456,0)
|
|
123.0
|
|
round(123.456,5)
|
|
123.456
|
|
round(123.456,2)
|
|
123.46
|
|
type(round(123.456,1))
|
|
<class 'float'>
|
|
type(round(123.456,0))
|
|
<class 'float'>
|
|
round(123.456)
|
|
123
|
|
type(round(123.456))
|
|
<class 'int'>
|
|
round(123.76)
|
|
124
|
|
```
|
|
|
|
#### 2.2 Изучаю функцию range
|
|
- Правая граница в создаваемую последовательность включена не будет
|
|
```py
|
|
gg=range(76,123,9)
|
|
type(gg)
|
|
<class 'range'>
|
|
```
|
|
- Преобразую в список
|
|
```py
|
|
list(gg)
|
|
[76, 85, 94, 103, 112, 121]
|
|
```
|
|
- Правая граница - 0, шаг по умолачнию 1.
|
|
```py
|
|
range(23)
|
|
range(0, 23)
|
|
list(range(23))
|
|
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
|
|
```
|
|
#### 2.3 Изучаю функцию zip
|
|
```py
|
|
qq = ["Антонов"]
|
|
type(qq)
|
|
<class 'list'>
|
|
type(qq[0])
|
|
<class 'str'>
|
|
qq.extend(['Корнеев','Ефимова','Гордиевских'])
|
|
qq
|
|
['Антонов', 'Корнеев', 'Ефимова', 'Гордиевских']
|
|
|
|
ff=zip(gg,qq)
|
|
ff
|
|
<zip object at 0x105131dc0>
|
|
|
|
tuple(ff)
|
|
((76, 'Антонов'), (85, 'Корнеев'), (94, 'Ефимова'), (103, 'Гордиевских'))
|
|
```
|
|
- Нельзя обратиться по индексу к объекту zip. Так как это «итерируемый объект» класса zip
|
|
```py
|
|
ff[0]
|
|
Traceback (most recent call last):
|
|
File "<pyshell#50>", line 1, in <module>
|
|
ff[0]
|
|
TypeError: 'zip' object is not subscriptable
|
|
|
|
list(ff)
|
|
[]
|
|
dict(ff)
|
|
{}
|
|
```
|
|
#### 2.4 Функция eval и exec
|
|
- eval - выполненяет код, который был передан в параметрах функции в виде строки
|
|
```py
|
|
коэффициент усиления=100
|
|
dan=eval('5*fff-156')
|
|
dan
|
|
344.0
|
|
eval('5')
|
|
5
|
|
```
|
|
- exec - выполняет множество инструкций
|
|
```py
|
|
exec(input('введите инструкции:'))
|
|
введите инструкции:perem=-123.456;gg=round(abs(perem)+98,3)
|
|
|
|
gg
|
|
221.456
|
|
|
|
perem
|
|
-123.456
|
|
|
|
exec("1")
|
|
|
|
exec("o=1")
|
|
o
|
|
1
|
|
#exec выполнит много команд, eval - одну
|
|
```
|
|
#### 2.5 Применяю стандартные функции
|
|
```py
|
|
abs(-1)
|
|
1
|
|
pow(2,2)
|
|
4
|
|
max(5,555)
|
|
555
|
|
min(5,555)
|
|
5
|
|
```
|
|
- Для sum можно использовать только итерируемый объект
|
|
```py
|
|
sum(5,555)
|
|
Traceback (most recent call last):
|
|
File "<pyshell#23>", line 1, in <module>
|
|
sum(5,555)
|
|
TypeError: 'int' object is not iterable
|
|
sum([5,555])
|
|
560
|
|
```
|
|
- divmod() принимает параметры a — делимое,b — делитель. Возвращает: кортеж (частное, остаток)
|
|
```py
|
|
divmod(9,9)
|
|
(1, 0)
|
|
|
|
len([1])
|
|
1
|
|
```
|
|
- map выполняет операцию (первый арумент) ко всем элементам второго аргумента
|
|
```py
|
|
numbers = [1, 2, 3, 4, 5]
|
|
result = map(str, numbers)
|
|
result
|
|
<map object at 0x10d47c3a0>
|
|
list(result)
|
|
['1', '2', '3', '4', '5']
|
|
```
|
|
### 3. Функции из стандартного модуля math
|
|
- Импортировал модуль, получил его содержимое
|
|
```py
|
|
import math
|
|
dir(math)
|
|
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'nextafter', 'perm', 'pi', 'pow', 'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'sumprod', 'tan', 'tanh', 'tau', 'trunc', 'ulp']
|
|
|
|
help(math.factorial)
|
|
Help on built-in function factorial in module math:
|
|
|
|
factorial(n, /)
|
|
Find n!.
|
|
```
|
|
- Применил часто встречающиеся функции
|
|
```py
|
|
math.factorial(5)
|
|
120
|
|
math.sin(5)
|
|
-0.9589242746631385
|
|
math.sin(90)
|
|
0.8939966636005579
|
|
math.sin(0)
|
|
0.0
|
|
math.sin(1800)
|
|
0.13220235275593667
|
|
math.acos(1)
|
|
0.0
|
|
math.acos(0)
|
|
1.5707963267948966
|
|
math.degrees(math.sin(1))
|
|
48.21273601220948
|
|
math.degrees(1)
|
|
57.29577951308232
|
|
math.degrees(9)
|
|
515.662015617741
|
|
math.radians(90)
|
|
1.5707963267948966
|
|
math.exp(1)
|
|
2.718281828459045
|
|
math.e
|
|
2.718281828459045
|
|
math.log(2)
|
|
0.6931471805599453
|
|
math.log10(10)
|
|
1.0
|
|
math.sqrt(25)
|
|
5.0
|
|
```
|
|
- Округление в большую и меньшую сторону
|
|
```py
|
|
math.ceil(2.2)
|
|
3
|
|
math.floor(2.2)
|
|
2
|
|
math.floor(2.9)
|
|
2
|
|
math.pi
|
|
3.141592653589793
|
|
```
|
|
- Вычисляю значение функции sin(2π/7+e0.23). Проверил через ранее изученную функцию 'eval'
|
|
```py
|
|
eval("math.sin(2*math.pi/7+math.e**0.23)")
|
|
0.8334902641414562
|
|
math.sin(2*math.pi/7+math.e**0.23)
|
|
0.8334902641414562
|
|
math.sin(2*math.pi/7+pow(math.e,0.23))
|
|
0.8334902641414562
|
|
```
|
|
### 4. Изучаю модуль для комплексных чисел - cmath
|
|
- Начал работу, импортировал
|
|
```py
|
|
import cmath
|
|
dir(cmath)
|
|
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atanh', 'cos', 'cosh', 'e', 'exp', 'inf', 'infj', 'isclose', 'isfinite', 'isinf', 'isnan', 'log', 'log10', 'nan', 'nanj', 'phase', 'pi', 'polar', 'rect', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau']
|
|
|
|
dir(cmath)
|
|
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atanh', 'cos', 'cosh', 'e', 'exp', 'inf', 'infj', 'isclose', 'isfinite', 'isinf', 'isnan', 'log', 'log10', 'nan', 'nanj', 'phase', 'pi', 'polar', 'rect', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau']
|
|
|
|
cmath.sqrt(1.2-0.5j) #формула Муавра
|
|
(1.118033988749895-0.22360679774997896j)
|
|
|
|
math.sqrt(1.2)
|
|
1.0954451150103321
|
|
|
|
cmath.phase(1-0.5j)
|
|
-0.4636476090008061
|
|
```
|
|
### 5. Изучаю модуль random для работы с выборками и числами
|
|
- Начал работу, импортировал
|
|
```py
|
|
import random
|
|
dir(random)
|
|
['BPF', 'LOG4', 'NV_MAGICCONST', 'RECIP_BPF', 'Random', 'SG_MAGICCONST', 'SystemRandom', 'TWOPI', '_ONE', '_Sequence', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_accumulate', '_acos', '_bisect', '_ceil', '_cos', '_e', '_exp', '_fabs', '_floor', '_index', '_inst', '_isfinite', '_lgamma', '_log', '_log2', '_os', '_parse_args', '_pi', '_random', '_repeat', '_sha512', '_sin', '_sqrt', '_test', '_test_generator', '_urandom', 'betavariate', 'binomialvariate', 'choice', 'choices', 'expovariate', 'gammavariate', 'gauss', 'getrandbits', 'getstate', 'lognormvariate', 'main', 'normalvariate', 'paretovariate', 'randbytes', 'randint', 'random', 'randrange', 'sample', 'seed', 'setstate', 'shuffle', 'triangular', 'uniform', 'vonmisesvariate', 'weibullvariate']
|
|
```
|
|
- random.seed - инициализирует генератор случайных чисел
|
|
```py
|
|
help(random.seed)
|
|
Help on method seed in module random:
|
|
|
|
seed(a=None, version=2) method of random.Random instance
|
|
Initialize internal state from a seed.
|
|
|
|
The only supported seed types are None, int, float,
|
|
str, bytes, and bytearray.
|
|
|
|
None or no argument seeds from current time or from an operating
|
|
system specific randomness source if available.
|
|
|
|
If *a* is an int, all bits are used.
|
|
|
|
For version 2 (the default), all of the bits are used if *a* is a str,
|
|
bytes, or bytearray. For version 1 (provided for reproducing random
|
|
sequences from older versions of Python), the algorithm for str and
|
|
bytes generates a narrower range of seeds.
|
|
|
|
random.seed()
|
|
|
|
dir(random)
|
|
['BPF', 'LOG4', 'NV_MAGICCONST', 'RECIP_BPF', 'Random', 'SG_MAGICCONST', 'SystemRandom', 'TWOPI', '_ONE', '_Sequence', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_accumulate', '_acos', '_bisect', '_ceil', '_cos', '_e', '_exp', '_fabs', '_floor', '_index', '_inst', '_isfinite', '_lgamma', '_log', '_log2', '_os', '_parse_args', '_pi', '_random', '_repeat', '_sha512', '_sin', '_sqrt', '_test', '_test_generator', '_urandom', 'betavariate', 'binomialvariate', 'choice', 'choices', 'expovariate', 'gammavariate', 'gauss', 'getrandbits', 'getstate', 'lognormvariate', 'main', 'normalvariate', 'paretovariate', 'randbytes', 'randint', 'random', 'randrange', 'sample', 'seed', 'setstate', 'shuffle', 'triangular', 'uniform', 'vonmisesvariate', 'weibullvariate']
|
|
```
|
|
#### 5.1 Применяю некоторые функции
|
|
- random() Возвращает случайное число с плавающей точкой в диапазоне от 0.0 до 1.0
|
|
```py
|
|
random.random()
|
|
0.008800222465144891
|
|
random.random()
|
|
0.7757718646112775
|
|
random.random()
|
|
0.6809534532050255
|
|
random.random()
|
|
0.4430922828704329
|
|
```
|
|
- uniform() Возвращает случайное число с плавающей точкой в заданном диапазоне
|
|
```py
|
|
random.uniform(1,20)
|
|
3.5170563248621844
|
|
random.uniform(1,20)
|
|
6.813290848556115
|
|
random.uniform(1,20)
|
|
18.150692296322372
|
|
```
|
|
- randint() - только целые числа
|
|
```py
|
|
random.randint(1,20)
|
|
5
|
|
random.randint(1,20)
|
|
6
|
|
random.randint(1,20)
|
|
12
|
|
```
|
|
- Изучаю различные законы распределения
|
|
```py
|
|
random.gauss()
|
|
-0.6902407757014835
|
|
random.gauss()
|
|
0.850255236263578
|
|
random.gauss()
|
|
1.379056097779261
|
|
random.gauss(10,0) #мат ожидание, дисперсия
|
|
10.0
|
|
|
|
random.choice([1,2,3,4,5])
|
|
4
|
|
random.choice([1,2,3,4,5])
|
|
3
|
|
random.choice([1,2,3,4,5])
|
|
1
|
|
random.choice((1,2,3,4,5))
|
|
4
|
|
```
|
|
- shuffle - меняет местами числа в последовательности. Принимает только итерируемый объект
|
|
```py
|
|
x = [21,12]
|
|
random.shuffle(x)
|
|
x
|
|
[12, 21]
|
|
|
|
x = (21,12)
|
|
random.shuffle(x)
|
|
Traceback (most recent call last):
|
|
File "<pyshell#40>", line 1, in <module>
|
|
random.shuffle(x)
|
|
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/random.py", line 361, in shuffle
|
|
x[i], x[j] = x[j], x[i]
|
|
TypeError: 'tuple' object does not support item assignment
|
|
|
|
random.betavariate(1,1)
|
|
0.36329048486741
|
|
random.gammavariate(1,1)
|
|
1.1185774335019822
|
|
|
|
lst = [random.random(),random.gauss(0,1),random.betavariate(0.1,1),random.gammavariate(0.1,1)]
|
|
lst
|
|
[0.5002931835956634, -1.6735958900161145, 1.7682636159174984e-12, 7.519855470126239e-06]
|
|
```
|
|
### 6. Модуль time
|
|
```py
|
|
import time
|
|
dir(time)
|
|
['CLOCK_MONOTONIC', 'CLOCK_MONOTONIC_RAW', 'CLOCK_MONOTONIC_RAW_APPROX', 'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME', 'CLOCK_THREAD_CPUTIME_ID', 'CLOCK_UPTIME_RAW', 'CLOCK_UPTIME_RAW_APPROX', '_STRUCT_TM_ITEMS', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'altzone', 'asctime', 'clock_getres', 'clock_gettime', 'clock_gettime_ns', 'clock_settime', 'clock_settime_ns', 'ctime', 'daylight', 'get_clock_info', 'gmtime', 'localtime', 'mktime', 'monotonic', 'monotonic_ns', 'perf_counter', 'perf_counter_ns', 'process_time', 'process_time_ns', 'sleep', 'strftime', 'strptime', 'struct_time', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'tzname', 'tzset']
|
|
```
|
|
- Время (секунды) начиная с эпохи Unix - 1970 1 января
|
|
```py
|
|
time.time()
|
|
1760033586.4494689
|
|
c1=time.time()
|
|
c2=time.time()-c1
|
|
c2
|
|
5.868124008178711
|
|
```
|
|
- Текущие сведения о времени UTC. Точка отсчета эпоха Unix
|
|
```py
|
|
time.gmtime()
|
|
time.struct_time(tm_year=2025, tm_mon=10, tm_mday=9, tm_hour=18, tm_min=15, tm_sec=47, tm_wday=3, tm_yday=282, tm_isdst=0)
|
|
```
|
|
- m_wday день недели 0-6 (0 - понедельник) tm_yday день года 1-366 tm_isdst летнее время 0
|
|
```py
|
|
dat=time.gmtime()
|
|
dat.tm_mon
|
|
10
|
|
|
|
time.gmtime().tm_year
|
|
2025
|
|
|
|
time.gmtime().tm_mday
|
|
9
|
|
time.gmtime().tm_hour
|
|
18
|
|
time.gmtime().tm_min
|
|
18
|
|
time.gmtime().tm_sec
|
|
56
|
|
time.gmtime().tm_wday
|
|
3
|
|
time.gmtime().tm_yday
|
|
282
|
|
time.gmtime().tm_isdst
|
|
0
|
|
|
|
time.localtime()
|
|
time.struct_time(tm_year=2025, tm_mon=10, tm_mday=9, tm_hour=21, tm_min=20, tm_sec=46, tm_wday=3, tm_yday=282, tm_isdst=0)
|
|
```
|
|
- asctime() - принимает кортеж в формате (year, month, day, hour, minute, second, weekday, yearday, isdst). По умолчанию текущее время
|
|
```py
|
|
time.asctime()
|
|
'Thu Oct 9 21:22:52 2025'
|
|
time.asctime(time.gmtime())
|
|
'Thu Oct 9 18:23:10 2025'
|
|
|
|
time.asctime(((2025, 1, 1, 12, 0, 0, 2, 1,0)))
|
|
'Wed Jan 1 12:00:00 2025'
|
|
```
|
|
- ctime() Вернет дату, с эпохи Unix. Принимает временя в секундах
|
|
```py
|
|
time.ctime(1)
|
|
'Thu Jan 1 03:00:01 1970' #прошло с начало эпохи в секундах
|
|
|
|
time.sleep(1)
|
|
```
|
|
- mktime покажет сколько прошло секунд сначала эпохи Unix
|
|
```py
|
|
time.mktime(time.localtime())
|
|
1760034468.0
|
|
time.localtime(c1)
|
|
time.struct_time(tm_year=2025, tm_mon=10, tm_mday=9, tm_hour=21, tm_min=14, tm_sec=40, tm_wday=3, tm_yday=282, tm_isdst=0)
|
|
time.localtime()
|
|
time.struct_time(tm_year=2025, tm_mon=10, tm_mday=9, tm_hour=21, tm_min=28, tm_sec=41, tm_wday=3, tm_yday=282, tm_isdst=0)
|
|
```
|
|
- Посмотрел доступные модули для работы со временем
|
|
```py
|
|
import datetime
|
|
dir(datetime)
|
|
['MAXYEAR', 'MINYEAR', 'UTC', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'timezone', 'tzinfo']
|
|
```
|
|
### 7. Графические функции
|
|
#### 7.1 Построение одного графика
|
|
```py
|
|
import matplotlib
|
|
from matplotlib import pylab
|
|
x=list(range(-3,55,4));t=list(range(15))
|
|
pylab.plot(t,x)
|
|
[<matplotlib.lines.Line2D object at 0x10dfe2350>]
|
|
|
|
pylab.title('Первый график')
|
|
Text(0.5, 1.0, 'Первый график')
|
|
|
|
pylab.xlabel('время')
|
|
Text(0.5, 23.52222222222222, 'время')
|
|
|
|
pylab.ylabel('сигнал')
|
|
Text(42.722222222222214, 0.5, 'сигнал')
|
|
|
|
pylab.show()
|
|
```
|
|

|
|
#### 7.2 Построение нескольких графиков на рисунке
|
|
```py
|
|
X1=[12,6,8,10,7];X2=[5,7,9,11,13]
|
|
pylab.plot(X1)
|
|
[<matplotlib.lines.Line2D object at 0x119cfd950>]
|
|
pylab.plot(X2)
|
|
[<matplotlib.lines.Line2D object at 0x10df70a50>]
|
|
pylab.show()
|
|
```
|
|

|
|
#### 7.3 Построение круговой диаграммы
|
|
```py
|
|
region=['Центр','Урал','Сибирь','Юг']
|
|
naselen=[65,12,23,17]
|
|
pylab.pie(naselen,labels=region)
|
|
([<matplotlib.patches.Wedge object at 0x10dea16a0>, <matplotlib.patches.Wedge object at 0x10dfb39d0>, <matplotlib.patches.Wedge object at 0x10dfb3d90>, <matplotlib.patches.Wedge object at 0x10dfb0050>], [Text(-0.19101313413904503, 1.0832885038559115, 'Центр'), Text(-0.861328292412156, -0.6841882582231001, 'Урал'), Text(0.04429273995539947, -1.0991078896938387, 'Сибирь'), Text(0.9873750693480946, -0.4848612919483732, 'Юг')])
|
|
pylab.show()
|
|
```
|
|

|
|
#### 7.4 Построение гистограммы
|
|
```py
|
|
data = list(range(1,50,10))
|
|
pylab.hist(data,bins = 10,edgecolor='red',label='ТЕСТ')
|
|
(array([1., 0., 1., 0., 0., 1., 0., 1., 0., 1.]), array([ 1., 5., 9., 13., 17., 21., 25., 29., 33., 37., 41.]), <BarContainer object of 10 artists>)
|
|
pylab.ylabel('количество попаданий в корзину')
|
|
Text(42.722222222222214, 0.5, 'количество попаданий в корзину')
|
|
pylab.xlabel('значения')
|
|
Text(0.5, 23.52222222222222, 'значения')
|
|
pylab.show()
|
|
```
|
|

|
|
#### 7.5 Построение диаграммы
|
|
```py
|
|
data = list(range(1,50,10))
|
|
categotia = [1,2,3,4,5]
|
|
|
|
data
|
|
[1, 11, 21, 31, 41]
|
|
|
|
pylab.xlabel('Категории')
|
|
Text(0.5, 23.52222222222222, 'Категории')
|
|
|
|
pylab.ylabel('Значение каждой категории')
|
|
Text(47.097222222222214, 0.5, 'Значение каждой категории')
|
|
|
|
pylab.bar(categotia,data,color='purple',label='TEST')
|
|
<BarContainer object of 5 artists>
|
|
|
|
pylab.show()
|
|
```
|
|

|
|
### 8. Изучаю состав статистического модуля statistics
|
|
```py
|
|
import statistics
|
|
|
|
dir(statistics)
|
|
['Counter', 'Decimal', 'Fraction', 'LinearRegression', 'NormalDist', 'StatisticsError', '_SQRT2', '__all__', '__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_coerce', '_convert', '_decimal_sqrt_of_frac', '_exact_ratio', '_fail_neg', '_float_sqrt_of_frac', '_integer_sqrt_of_frac_rto', '_isfinite', '_kernel_invcdfs', '_mean_stdev', '_newton_raphson', '_normal_dist_inv_cdf', '_quartic_invcdf', '_quartic_invcdf_estimate', '_random', '_rank', '_sqrt_bit_width', '_sqrtprod', '_ss', '_sum', '_triweight_invcdf', '_triweight_invcdf_estimate', 'acos', 'asin', 'atan', 'bisect_left', 'bisect_right', 'correlation', 'cos', 'cosh', 'count', 'covariance', 'defaultdict', 'erf', 'exp', 'fabs', 'fmean', 'fsum', 'geometric_mean', 'groupby', 'harmonic_mean', 'hypot', 'isfinite', 'isinf', 'itemgetter', 'kde', 'kde_random', 'linear_regression', 'log', 'math', 'mean', 'median', 'median_grouped', 'median_high', 'median_low', 'mode', 'multimode', 'namedtuple', 'numbers', 'pi', 'pstdev', 'pvariance', 'quantiles', 'random', 'reduce', 'repeat', 'sin', 'sqrt', 'stdev', 'sumprod', 'sys', 'tan', 'tau', 'variance']
|
|
import statistics as st
|
|
help(st.sin)
|
|
Help on built-in function sin in module math:
|
|
|
|
sin(x, /)
|
|
Return the sine of x (measured in radians).
|
|
|
|
help(st.math)
|
|
|
|
dir(st.math)
|
|
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'nextafter', 'perm', 'pi', 'pow', 'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'sumprod', 'tan', 'tanh', 'tau', 'trunc', 'ulp']
|
|
|
|
dir(st.tau)
|
|
['__abs__', '__add__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getformat__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__pow__', '__radd__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '__rmul__', '__round__', '__rpow__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', 'as_integer_ratio', 'conjugate', 'fromhex', 'hex', 'imag', 'is_integer', 'real']
|
|
|
|
st.tau
|
|
6.283185307179586
|
|
st.tau
|
|
6.283185307179586
|
|
|
|
math.pi*2 == st.tau
|
|
True
|
|
|
|
data = list(st.repeat([1,2,3],5))
|
|
data
|
|
[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]
|
|
``` |