Cuts¶
An administration is going to apply several cuts to its workers’
salaries and needs to design the following functions, that will be
saved into the same file cuts.py.
A modifier function named
cut()that takes a list of monthly salaries (float) and a percentage (float) corresponding to the cut to be applied to the salaries, and modifies the salaries list by applying this percentage to all its elements. Examples:>>> list_salaries = [1250, 2000, 1000, 3000, 2400] >>> cut (list_salaries, 5) >>> for salary in list_salaries: ... print(round(salary,2)) 1187.5 1900.0 950.0 2850.0 2280.0
Note
More tests are provided in file
cuts1.txtAnother function named
administration()that receives a list of workers, a percentage corresponding to the salaries’ cuts and a threshold salary, i.e., a salary value such that the cut will not be applied to salaries greater to this threshold. The list of workers is a list of sublists. Each sublist consists of two elements: the name of the worker and his/her monthly salary. The function must return a list of real numbers corresponding to the salaries lower than the given threshold salary and with the salary cut applied. Moreover, in this list there must not be repeated salaries and they have to be sorted increasingly. This function must use the previous one. Examples:>>> list_work = [['josep', 1250], ['rodrigo', 100000], ['jaume', 2000], ... ['artur', 40000], ['anna', 1000], ['ursula', 1250], ['enric', 3000], ... ['magda',2000], ['mariano', 70000]] >>> list_salary = administration (list_work, 5, 5000) >>> for salary in list_salary: ... print(round(salary,1)) 950.0 1187.5 1900.0 2850.0
Note
More tests are provided in the
cuts2.txt
Solutions
A solution of these functions is provided in the cuts.py