Python Tasks & ML | ΠΠ°Π΄Π°ΡΠΈ ΠΏΠΎ ΠΏΠΈΡΠΎΠ½Ρ ΠΈ ΠΌΠ°ΡΠΈΠ½Π½ΠΎΠΌΡ ΠΎΠ±ΡΡΠ΅Π½ΠΈΡ
Open in Telegram
Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn https://telega.in/c/python_tasks Questions β @dina_ladnyuk
Show more8 557
Subscribers
No data24 hours
-37 days
-3430 days
Posts Archive
ΠΠ°Π½ ΠΊΠΎΠ΄
def f(a, b, c, d):
print(a, b, c, d)ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
def func(a, b):
Π° = 2
b[0] = 10
x = 1
y = 1, 2
func(x, y)
print(x, y)ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
def func(Π°, b):
Π° = 2
b = b[:]
b[0] = 10
a, b = [0], [1]
func(a, b)
print(a, b)ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
def f():
x = 1
def g():
x += 1
g()
print(x)
print(f())ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
a = b, c = [1, 2]
a[0] = 10
print(b, c)ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
def f(name="", value=0):
import sys
func_name = sys._getframe(0).f_code.co_name
func = sys._getframe(1).f_locals[func_name]
setattr(func, name, value)
return sum(func.__dict__.values())
print(f("x", 1), f("y", 2), f())ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
def f():
def g():
global x
x = 2
g()
print(x)
f()ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
def f():
def g():
nonlocal x
x = 2
g()
print(x)
f()ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
my_list = [1, 2, 3, 4, 5]
r = [x % 3 for x in my_list]
print(sum(r))ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
Π§ΡΠΎ Π²ΡΠ²Π΅Π΄Π΅Ρ ΠΊΠΎΠ΄?
a, b = {1, 2}, {2, 3}
c = a - b
d = b - a
print(*(c & d), *(c | d))ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ Π²Π°ΡΠΈΠ°Π½Ρ
