Discounts

  1. A shop offers a discount of 5€ if the total amount of the purchase, including VAT, is more than 50€. Write the function discount1() that given the amount of the purchase (without VAT) and the VAT percentage to be applied (float), returns the total amount to pay (float). Save this function into a file named discount1.py. Examples:

    
    >>> round(discount1(45, 10), 2)
    49.5
    >>> round(discount1(45, 16), 2)
    47.2
    >>> round(discount1(40, 25), 2)
    50.0
    

    Note

    More tests are provided in the discount1.txt

  2. A shop offers a discount of 5€ if the total amount of the purchase, including VAT, is more than 100€ and a discount of 2€ if the purchase is lower or equal to 100€. Write the function discount2() that given the amount of money of the purchase (without VAT) and the VAT to be applied (float), returns the total amount to pay (float). Suppose that the purchase is always higher than 2€. Save this function into a file named discount2.py. Examples:

    
    >>> round(discount2(93, 10), 2)
    97.3
    >>> round(discount2(45, 16), 2)
    50.2
    >>> round(discount2(80, 25), 2)
    98.0
    >>> round(discount2(81, 25), 2)
    96.25
    

    Note

    More tests are provided in the discount2.txt

  3. A shop offers a discount of 5€ if the total amount of the purchase, including VAT, is more than 100€, a discount of 10€ if the purchase is higher than 150€ and a discount of 20€ if the purchase is higher than 250€. Only one discount can be applied. Write the function discount3() that given the amount of money of the purchase (without VAT) and the VAT to be applied (float), returns the total amount to pay (float). Save this function into a file named discount3.py. Examples:

    
    >>> round(discount3(90, 10), 2)
    99.0
    >>> round(discount3(93, 10), 2)
    97.3
    >>> round(discount3(80, 25), 2)
    100.0
    >>> round(discount3(115, 21), 2)
    134.15
    >>> round(discount3(120, 25), 2)
    145.0
    >>> round(discount3(223, 16), 2)
    238.68
    

    Note

    More tests are provided in the discount3.txt

  4. A shop offers a discount of 5€ if the total amount of the purchase, including VAT, is more than 100€. Moreover, if the client buys more than 5 units of the product, it offers an additional discount of 3€. Write the function discount4() that given the amount of money of the purchase (without VAT), the VAT to be applied (float) and the number of units bought (int), returns the total amount to pay (float).Save this function into a file named discount4.py. Examples:

    
    >>> round(discount4(90, 10, 1), 2)
    99.0
    >>> round(discount4(12, 21, 6), 2)
    87.12
    >>> round(discount4(80, 25, 1), 2)
    100.0
    >>> round(discount4(45, 21, 2), 2)
    103.9
    >>> round(discount4(23.2, 16, 7), 2)
    180.38
    
    

    Note

    More tests are provided in the discount4.txt

Solutions

A solution of these functions is provided in the discount1.py, discount2.py, discount3.py, discount4.py