First of all, sorry for my English (not my native language). I am new to Python (or any type of programing).
I have a .txt
file with 5 columns (column header not in file):
name, age, occupation, salary, years_in_the_company
I need to write a code for a function that prints out a dictionary with the following:
{
'average_age': $avg,
'best_paid_job': $best_paid,
'best_paid_employee': $best_paid_employee,
'no_employees': $no_employees,
'top_3_jobs': [$job1,$job2, $job3],
'seniors': $no_seniors,
'middle': $no_middle,
'juniors': $no_juniors'
}
where
$ avg: float representing the average age of employees.
$ best_paid_job: int, the highest value for salary.
$ best_paid_employee: string, the name of the employee with the highest salary.
$ no_employees: int, number of employees.
$ top_3_jobs: List of strings representing the most common 3 jobs.
$ no_seniors: The number of senior employees in the company. They are all considered to be seniors employees who have more than 5 years of seniority in the company ,'years_in_the_company' 'is greater than 5).
$ no_middle: The number of middle employees in the company. They are all considered middle employees aged 3-5 years.
$ no_junior: The number of junior employees in the company. All are considered junior employees aged less than 3 years.
The trick is I can't use any predefined Python functions (ex. csv, numpy..) I need basic code.
Can you guys help with that part of the code? I am trying my brains out for the last week and nothing works
This is my file (data.txt)
Helen 20 Network Designer 5449 9
Jasmine 40 Software Architect 2536 1
Phoebe 28 Software Engineer 2627 7
Aysha 34 Software Developer 6441 3
Madeleine 26 Systems Engineer 5948 6
Christina 27 Python Developer 8366 5
Melissa 29 Data Scientist 6262 4
Marie 44 Researcher 6936 6
Tamara 40 System Administrator 9727 1
Freya 43 Software Engineer in Test 5686 10
Charles 43 System Administrator 3114 8
John 24 Software Engineer in Test 7035 4
Joe 30 Network Designer 2916 4
Elmer 37 Software Architect 4641 10
Tobias 38 Systems Engineer 5757 7
Samuel 43 Python Developer 4092 7
Casey 43 Systems Engineer 5318 1
Otis 45 Software Architect 3356 2
Frank 37 Python Developer 8111 1
Hugo 37 Software Architect 4632 5
Justin 35 Python Developer 2260 7
Jessie 39 System Administrator 4162 6