Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks
Questions — @dina_ladnyuk
Post #1449
3.17K
- 👍 23
PY @python_tasks
Showing posts older than #1450 · Back to latest
import numpy as np
Polynomial = np.polynomial.Polynomial
p = Polynomial([1, -1])
q = Polynomial([1, 1])
print(int((p * q)(2)))
import numpy as np
Polynomial = np.polynomial.Polynomial
p = Polynomial([1, -1, 1])
q = Polynomial([2, -3])
print(int((p + q)(1)))
import numpy as np
Polynomial = np.polynomial.Polynomial
p = Polynomial([6, -3, 1])
print(int(p(0)), int(p(1)), int(p(2)))
import numpy as np
data = np.array([2, 7, 3, 1])
bins = [0, 5, 10]
hist, _ = np.histogram(data, bins)
print(*hist)
#data - набор данных
#bins - набор интервалов, задаваемых граничными значениями
import numpy as np
x = np.array([1., 2., np.nan])
print(np.nanstd(x))
import numpy as np
x = np.array([1, 2])
print(np.std(x))
import numpy as np
x = np.array([1, 2, 3, 4])
print(np.average(x, weights=[2, 1, 0, 5]))
import numpy as np
x = np.array([1, 4, 9, 16])
print(np.median(x))
import numpy as np
x = np.array([1, 4, 9, 16])
print(np.mean(x))