Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Generate Employee Report | Reporting and Insights for HR
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for HR Specialists

bookChallenge: Generate Employee Report

As you move further into reporting and insights in HR, it is crucial to be comfortable iterating through lists of dictionaries and performing calculations based on their contents. In previous chapters, you have already worked with employee data structured as dictionaries, each containing fields such as name, department, and tenure. These skills allow you to efficiently count, summarize, and analyze HR information for reporting purposes.

When you need to generate an employee report, you often start by traversing the employee list. For each employee, you extract the department and tenure, and then use this information to compute totals, averages, and groupings. This process not only helps in summarizing the workforce but also in identifying trends and making data-driven decisions.

123456789101112131415161718192021222324252627
employees = [ {"name": "Alice", "department": "HR", "tenure": 3}, {"name": "Bob", "department": "Finance", "tenure": 5}, {"name": "Charlie", "department": "HR", "tenure": 2}, {"name": "Diana", "department": "IT", "tenure": 4}, {"name": "Eve", "department": "Finance", "tenure": 1} ] # Count employees per department dept_counts = {} for emp in employees: dept = emp["department"] if dept not in dept_counts: dept_counts[dept] = 0 dept_counts[dept] += 1 print("Employee count per department:") for dept, count in dept_counts.items(): print(f"{dept}: {count}") # Calculate average tenure total_tenure = 0 for emp in employees: total_tenure += emp["tenure"] average_tenure = total_tenure / len(employees) print(f"Average tenure: {average_tenure:.2f} years")
copy

When formatting a report for HR, clarity and organization are key. Use clear headings such as Employee Report or Departments to divide sections. Align numbers for readability and use consistent spacing. Consider breaking the report into logical parts: a title, a summary of total employees, a section listing departments with their respective employee counts, and a final section showing the average tenure. This structure ensures that your report is both informative and easy to read, making it valuable for stakeholders who rely on these insights for decision-making.

Compito

Swipe to start coding

Write a function that prints a formatted employee report using the provided list of employee dictionaries. The report must include the following sections:

  • A title at the top of the report.
  • The total number of employees.
  • A list of departments with the count of employees in each.
  • The average tenure of all employees, rounded to two decimal places.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 3
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

bookChallenge: Generate Employee Report

Scorri per mostrare il menu

As you move further into reporting and insights in HR, it is crucial to be comfortable iterating through lists of dictionaries and performing calculations based on their contents. In previous chapters, you have already worked with employee data structured as dictionaries, each containing fields such as name, department, and tenure. These skills allow you to efficiently count, summarize, and analyze HR information for reporting purposes.

When you need to generate an employee report, you often start by traversing the employee list. For each employee, you extract the department and tenure, and then use this information to compute totals, averages, and groupings. This process not only helps in summarizing the workforce but also in identifying trends and making data-driven decisions.

123456789101112131415161718192021222324252627
employees = [ {"name": "Alice", "department": "HR", "tenure": 3}, {"name": "Bob", "department": "Finance", "tenure": 5}, {"name": "Charlie", "department": "HR", "tenure": 2}, {"name": "Diana", "department": "IT", "tenure": 4}, {"name": "Eve", "department": "Finance", "tenure": 1} ] # Count employees per department dept_counts = {} for emp in employees: dept = emp["department"] if dept not in dept_counts: dept_counts[dept] = 0 dept_counts[dept] += 1 print("Employee count per department:") for dept, count in dept_counts.items(): print(f"{dept}: {count}") # Calculate average tenure total_tenure = 0 for emp in employees: total_tenure += emp["tenure"] average_tenure = total_tenure / len(employees) print(f"Average tenure: {average_tenure:.2f} years")
copy

When formatting a report for HR, clarity and organization are key. Use clear headings such as Employee Report or Departments to divide sections. Align numbers for readability and use consistent spacing. Consider breaking the report into logical parts: a title, a summary of total employees, a section listing departments with their respective employee counts, and a final section showing the average tenure. This structure ensures that your report is both informative and easy to read, making it valuable for stakeholders who rely on these insights for decision-making.

Compito

Swipe to start coding

Write a function that prints a formatted employee report using the provided list of employee dictionaries. The report must include the following sections:

  • A title at the top of the report.
  • The total number of employees.
  • A list of departments with the count of employees in each.
  • The average tenure of all employees, rounded to two decimal places.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 3
single

single

some-alt