Балашов Георгий Сергеевич, 403 группа RndSwissknife 16615
Шаргаровский Михаил Денисович, 402 группа RndSwissknife 16764
f1import randomf1import random
2from collections.abc import Iterable, Sequence2from collections.abc import Iterable, Sequence
33
4def rnd(a, b=None):4def rnd(a, b=None):
5    match (a, b):5    match (a, b):
6        case [int(), None]:6        case [int(), None]:
7            return random.randint(0, a)7            return random.randint(0, a)
8        case [int(), int()]:8        case [int(), int()]:
9            return random.randint(a, b)9            return random.randint(a, b)
n10        case [float(), float() | int()]:n10        case [float(), int() | float()]:
11            return random.uniform(a, b)11            return random.uniform(a, b)
12        case [str(), int()]:12        case [str(), int()]:
t13            x = random.randint(0, len(a) - b)t13            start = random.randint(0, len(a) - b)
14            return a[x:x + b]14            return a[start:start + b]
15        case [str(), None]:15        case [str(), None]:
16            return random.choice(a.split())16            return random.choice(a.split())
17        case [str(), str()]:17        case [str(), str()]:
18            return random.choice(a.split(b))18            return random.choice(a.split(b))
19        case [Iterable() | Sequence(), None]:19        case [Iterable() | Sequence(), None]:
20            return random.choice(list(a))20            return random.choice(list(a))
21        case [Iterable() | Sequence(), int()]:21        case [Iterable() | Sequence(), int()]:
22            return random.choices(list(a), k=b)22            return random.choices(list(a), k=b)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op