summaryrefslogtreecommitdiff
path: root/doc/data/messages/t/too-complex/bad.py
blob: 8d6d78b824c12ea4ee5e7de525a457456f04d7d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def fifty_percent_off(whole):
    return (float(whole)) * 50 / 100


def calculate_sum_and_display_price_of_fruits(*fruits):  # [too-complex]
    # McCabe rating is 13 here (by default 10)
    shopping_list = []

    if "apple" in fruits:
        v = fifty_percent_off(1.1)
        shopping_list.append(v)
    if "pear" in fruits:
        shopping_list.append(0.8)
    if "banana" in fruits:
        shopping_list.append(1.2)
    if "mango" in fruits:
        shopping_list.append(3.5)
    if "peach" in fruits:
        shopping_list.append(0.5)
    if "melon" in fruits:
        shopping_list.append(4.9)
    if "orange" in fruits:
        shopping_list.append(2.0)
    if "strawberry" in fruits:
        shopping_list.append(2.5)
    if "mandarin" in fruits:
        shopping_list.append(2.3)
    if "plum" in fruits:
        shopping_list.append(0.5)
    if "watermelon" in fruits:
        v = fifty_percent_off(6.4)
        shopping_list.append(v)

    combine = zip(fruits, shopping_list)

    for i in combine:
        print(f"{i[0]} ${i[1]:.2f}")

    total = sum(shopping_list)
    print(f"Total price is ${total:.2f}")


fruits_to_buy = ["apple", "orange", "watermelon"]
calculate_sum_and_display_price_of_fruits(*fruits_to_buy)