Being out of work is not the same as being unemployed in the official sense. A town's labour survey asks each person four things about a reference week and records the answers as a tuple (age, hours, looked, available):
agein whole years;hoursworked for pay that week (a whole number);looked:Trueif the person actively looked for a job at some time in the last four weeks;available:Trueif the person could start a job within two weeks.
The definitions, in this order:
- Only people aged 16 or over are of working age; everyone younger is left out of every count.
- Employed: worked at least 1 hour for pay that week (whatever they answered about looking).
- Unemployed: worked 0 hours, and looked, and is available.
- Everyone else of working age is not in the labour force (students, retired people, carers, and people who have given up looking).
The labour force is the employed plus the unemployed. Write labour_rates(people) that returns the tuple
\left(\frac{\text{unemployed}}{\text{labour force}},\ \frac{\text{labour force}}{\text{working age}},\ \frac{\text{employed}}{\text{working age}}\right)
as fractions (0.05 means 5 %): the unemployment rate, the participation rate and the employment rate. A rate whose denominator is 0 is None.
Examples
Input: people = [(34, 40, False, True), (19, 0, True, True), (67, 0, False, False),
(15, 10, False, True), (45, 2, True, True), (28, 0, True, False)]
Output: (0.3333333333333333, 0.6, 0.4)
Explanation: the 15-year-old is left out, so 5 people are of working age. The 34- and
45-year-olds are employed (2 hours is enough), the 19-year-old is unemployed, and the
retiree and the 28-year-old who cannot start yet are outside the labour force.
Labour force 3: unemployment 1/3, participation 3/5, employment 2/5.
Input: people = [(70, 0, False, False)]
Output: (None, 0.0, 0.0)
Constraints
- floats are compared with a tolerance of
1e-6
Goals
- Sort survey answers into employed, unemployed and not in the labour force
- Compute the unemployment rate over the labour force, not over everyone
- Handle a survey with nobody of working age or nobody in the labour force