c = filter(lambda x: x ** x, map(lambda x: x ^ x, (1, 2, 3, 4))) print(*c)
Задачи по питону и машинному обучению: алгоритмы, функции, классы, регулярные выражения, итераторы, генераторы, ООП, исключения, numpy, pandas, matplotlib, scikit-learn, TensorFlow и др. #Python #ml
c = filter(lambda x: x ** x, map(lambda x: x ^ x, (1, 2, 3, 4))) print(*c)
c = map(lambda x: x ** x, filter(lambda x: x % 2, (1, 2, 3, 4))) print(*c)
f = lambda i, sign: sign * (i**2 + 7) // (i**3 + 34) g = lambda i, sign: sign * (i**6 + 1) // (i ** 2 + i + 121) h = lambda f: sum(f(i, 1) + f(i, -1) for i in range(1000)) print(h(f) + h(g))
x= -7 // 3 == -(7 // 3) y = -7 // -3 == 7 // 3 print(x, y)
from fractions import Fraction x = 0.375 y = Fraction(*x.as_integer_ratio()) print(y)
from sklearn.cluster import KMeans import numpy as np x = np.array([[35, 7000], [45, 6900], [70, 7100], [20, 2000], [25, 2200], [15, 1800]]) kmeans = KMeans(n_clusters=2).fit(x) y = kmeans.cluster_centers_ print(y)
from fractions import Fraction a = Fraction(1, 3) b = Fraction(1, 4) c = a + b d = c.limit_denominator(2) print(d)
from fractions import Fraction a = Fraction(2, 3) b = Fraction(1, 2) print(a - b)
from math import isnan
c = float('nan')
i = 0
if c == float('nan'):
i += 1
if c is float('nan'):
i += 1
if isnan(c):
i += 1
print(i)import math
a = float('nan')
b = a + 10
c = a / 2
d = a * 2
e = math.sqrt(a)
print(a == b, b == c, a == c, c == d, a == d, d == e, a == e)a = float('inf')
b = a * 10
c = 10 / a
d = a / 10
print(b, c, d)from math import isinf, isnan
e = float('inf') + float('nan')
g = float('nan') / float('nan')
print(isinf(e), isinf(g), isnan(e), isnan(g))import math
a = float('inf')
b = float('-inf')
c = a - b
d = a + b
print(math.isinf(c), math.isinf(d), math.isnan(c), math.isnan(d))