Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks
Questions — @dina_ladnyuk
Post #2080
2.01K
- 👍 6
PY @python_tasks
Showing posts older than #2081 · Back to latest
import datetime
t1 = datetime.date(2021, 3, 5) - datetime.date(2021, 2, 23)
t2 = datetime.date(2020, 3, 5) - datetime.date(2020, 2, 23)
print((t2 - t1).days)
fs1 = [lambda: i for i in range(2)]
fs2 = (lambda: i for i in range(2))
x1, y1 = fs1[0](), fs1[1]()
x2, y2 = next(fs2)(), next(fs2)()
print(x1, y1, x2, y2)
-453492 % 101 + 453492 % 101
def f(arr):
return 0 if not arr else arr[0] + f(arr[1:])
print(f([1, 2]))
import math
sum(map(math.sqrt, (x ** 2 for x in range(3))))
#1
sorted(x ** 2 for x in range(4))
#2
sorted((x ** 2 for x in range(4)))
#3
sorted((x ** 2 for x in range(4)), reverse=True)
#4
sorted(x ** 2 for x in range(4), reverse=True)
#5
list(x ** 2 for x in range(4))
def gen():
for i in range(1, 5):
x = yield i
if x:
yield x**2
g = gen()
v = g.send(g.send(next(g) + next(g)) + next(g))
print(v)
listoftuple = [(0, 1, 2), (1, 2, 3)]
s1 = [b for (a, b, c) in listoftuple]
print(s1)
s2 = list(map(lambda row: row[1], listoftuple))
print(s1 == s2, sum(s1))
res = [х ** у for х in [2, 3] for у in [2, 3]]
print(res)