Fidelity

A bank has a system for customer’s loyalty. The system awards a customer with points which are based on the amount of each purchase of his/her credit card. Each month, the customer receives a notification with the accumulated number of points which can be exchanged for gifts. Points are given according to these criteria:

  • for an amount less than € 10: 1 point

  • for an amount greater than or equal to € 10: 3 points for every € 5

An amount of € 1000 or more has an additional bonus of 50 points.

Save the two following functions into a file named fidelity.py.

  1. Write the function compute_points() that takes a purchase amount (float), and returns the correspondig number of points (integer).

    See the following examples:

    >>> compute_points(7.8)
    1
    >>> compute_points(10.0)
    6
    >>> compute_points(75.9)
    45
    >>> compute_points(1000.0)
    650
    >>> compute_points(1236.8)
    791
    

    Note

    More tests are provided in the compute_points.txt file.

  2. Write the function update_points() that takes a customer number of accumulated points (integer) and a purchase amount (float), and returns the final number of accumulated points of this customer, taking into account this purchase. This function must call the previous function compute_points().

    See the following examples:

    >>> update_points(33, 7.8)
    34
    >>> update_points(0, 10.0)
    6
    >>> update_points(23, 75.9)
    68
    >>> update_points(2, 1000.0)
    652
    >>> update_points(564, 1236.8)
    1355
    

    Note

    More tests are provided in the update_points.txt file.

Solution

A solution is provided in the fidelity.py file.