1def function_that_says_ni(*args, **kwargs):
2 cost = 0
3 letters = set()
4 nice_trees = ("храст", "shrub", "bush")
5 for arg in args:
6 if type(arg) is dict:
7 if "name" in arg:
8 if arg["name"].lower() in nice_trees:
9 if "cost" in arg:
10 cost += arg["cost"]
11
12 for arg in kwargs:
13 if type(kwargs[arg]) is dict:
14 if "name" in kwargs[arg]:
15 if kwargs[arg]["name"].lower() in nice_trees:
16 for letter in arg:
17 if letter.isalpha() or letter == '_':
18 letters.add(letter)
19 if "cost" in kwargs[arg]:
20 cost += kwargs[arg]["cost"]
21
22 if cost > 42 or int(cost) == 0:
23 return "Ni!"
24 if len(letters) % int(cost) == 0:
25 return f"{format(cost,'.2f')}лв"
26 return "Ni!"
27
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
f | 1 | def function_that_says_ni(*args, **kwargs): | f | 1 | def function_that_says_ni(*args, **kwargs): |
n | 2 | cost = 0.0 | n | 2 | cost = 0 |
3 | letters=set() | 3 | letters = set() | ||
4 | nice_trees = ("храст", "shrub", "bush") | ||||
4 | for arg in args: | 5 | for arg in args: | ||
5 | if type(arg) is dict: | 6 | if type(arg) is dict: | ||
6 | if "name" in arg: | 7 | if "name" in arg: | ||
n | 7 | if arg["name"].lower() in ("храст", "shrub", "bush"): | n | 8 | if arg["name"].lower() in nice_trees: |
8 | if "cost" in arg: | 9 | if "cost" in arg: | ||
9 | cost += arg["cost"] | 10 | cost += arg["cost"] | ||
n | 10 | n | 11 | ||
11 | for arg in kwargs: | 12 | for arg in kwargs: | ||
12 | if type(kwargs[arg]) is dict: | 13 | if type(kwargs[arg]) is dict: | ||
13 | if "name" in kwargs[arg]: | 14 | if "name" in kwargs[arg]: | ||
n | 14 | if kwargs[arg]["name"].lower() in ("храст", "shrub", "bush"): | n | 15 | if kwargs[arg]["name"].lower() in nice_trees: |
15 | for letter in arg: | 16 | for letter in arg: | ||
16 | if letter.isalpha() or letter == '_': | 17 | if letter.isalpha() or letter == '_': | ||
17 | letters.add(letter) | 18 | letters.add(letter) | ||
18 | if "cost" in kwargs[arg]: | 19 | if "cost" in kwargs[arg]: | ||
19 | cost += kwargs[arg]["cost"] | 20 | cost += kwargs[arg]["cost"] | ||
20 | 21 | ||||
21 | if cost > 42 or int(cost) == 0: | 22 | if cost > 42 or int(cost) == 0: | ||
t | 22 | return("Ni!") | t | 23 | return "Ni!" |
23 | else: | ||||
24 | if len(letters) % int(cost) == 0: | 24 | if len(letters) % int(cost) == 0: | ||
25 | return(f"{format(cost,'.2f')}лв") | 25 | return f"{format(cost,'.2f')}лв" | ||
26 | return("Ni!") | 26 | return "Ni!" | ||
27 | 27 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def function_that_says_ni(*args, **kwargs): | f | 1 | def function_that_says_ni(*args, **kwargs): |
2 | cost = 0.0 | 2 | cost = 0.0 | ||
3 | letters=set() | 3 | letters=set() | ||
n | n | 4 | for arg in args: | ||
5 | if type(arg) is dict: | ||||
6 | if "name" in arg: | ||||
7 | if arg["name"].lower() in ("храст", "shrub", "bush"): | ||||
8 | if "cost" in arg: | ||||
9 | cost += arg["cost"] | ||||
10 | |||||
4 | for arg in kwargs: | 11 | for arg in kwargs: | ||
5 | if type(kwargs[arg]) is dict: | 12 | if type(kwargs[arg]) is dict: | ||
6 | if "name" in kwargs[arg]: | 13 | if "name" in kwargs[arg]: | ||
7 | if kwargs[arg]["name"].lower() in ("храст", "shrub", "bush"): | 14 | if kwargs[arg]["name"].lower() in ("храст", "shrub", "bush"): | ||
8 | for letter in arg: | 15 | for letter in arg: | ||
9 | if letter.isalpha() or letter == '_': | 16 | if letter.isalpha() or letter == '_': | ||
10 | letters.add(letter) | 17 | letters.add(letter) | ||
11 | if "cost" in kwargs[arg]: | 18 | if "cost" in kwargs[arg]: | ||
12 | cost += kwargs[arg]["cost"] | 19 | cost += kwargs[arg]["cost"] | ||
13 | 20 | ||||
n | 14 | for arg in args: | n | ||
15 | if type(arg) is dict: | ||||
16 | if "name" in arg: | ||||
17 | if arg["name"].lower() in ("храст", "shrub", "bush"): | ||||
18 | if "cost" in arg: | ||||
19 | cost += arg["cost"] | ||||
20 | |||||
21 | if cost > 42 or int(cost) == 0: | 21 | if cost > 42 or int(cost) == 0: | ||
22 | return("Ni!") | 22 | return("Ni!") | ||
23 | else: | 23 | else: | ||
24 | if len(letters) % int(cost) == 0: | 24 | if len(letters) % int(cost) == 0: | ||
25 | return(f"{format(cost,'.2f')}лв") | 25 | return(f"{format(cost,'.2f')}лв") | ||
26 | return("Ni!") | 26 | return("Ni!") | ||
27 | 27 | ||||
t | 28 | print(function_that_says_ni({"name": "храсТ", "cost": 3.20})) | t | ||
29 | print(function_that_says_ni(4, a=5)) | ||||
30 | print(function_that_says_ni()) | ||||
31 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 1})) | ||||
32 | print(function_that_says_ni(b={"name": "храст", "cost": 1.80}, bc={"name": "храс0т", "cost": 1})) | ||||
33 | print(function_that_says_ni({"name": "храст", "cost": 120})) | ||||
34 | print(function_that_says_ni({"name": "храст", "cost": 1})) | ||||
35 | print(function_that_says_ni(aabcc={"name": "bush", "cost": 3.20})) | ||||
36 | |||||
37 | print(function_that_says_ni({"ddd": "храст", "cost": 1.50}, {"namae": "sHRub", "cost": 3.00})) #ni | ||||
38 | print(function_that_says_ni({"name": "храст"}, {"name": "храст", "cost": 0.0}, ["ffffffffff", {1, 2, 3}]))#ni | ||||
39 | print(function_that_says_ni({"name": "храст"}, {"name": "bush", "cost": 33.33}))#33.33 | ||||
40 | print(function_that_says_ni({"name": "храст"}, {"name": "buSh"}))#ni | ||||
41 | print(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"))#11.00 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|