Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Yearly Turnover Analysis | Analyzing Employee Data
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for HR Specialists

bookChallenge: Yearly Turnover Analysis

You have learned how to use Python lists to store HR data and how to perform calculations using elements from these lists. When analyzing employee turnover, it is common to have two lists: one containing the number of employee departures for each year, and another containing the average headcount for each year. By processing these lists element-wise, you can calculate important HR metrics such as the turnover rate for each year.

1234567
departures_per_year = [8, 10, 7, 12] average_headcount_per_year = [80, 85, 83, 90] years = [2020, 2021, 2022, 2023] for year, departures, headcount in zip(years, departures_per_year, average_headcount_per_year): turnover_rate = departures / headcount print(f"Year: {year} - Turnover Rate: {turnover_rate:.2%}")
copy

When presenting turnover rates, it is helpful to display both the year and the calculated percentage in a clear format. You can use Python's formatted string literals (f-strings) to include the year and format the turnover rate as a percentage with two decimal places. This makes your output easy for stakeholders to read and interpret.

Aufgabe

Swipe to start coding

Write a function that prints the turnover rate for each year using the provided lists: years, departures, and headcounts.

  • For each year, calculate the turnover rate as the number of departures divided by the average headcount.
  • Format the turnover rate as a percentage with two decimal places.
  • Print a line for each year in the format: "Year: - Turnover Rate: %".

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 5
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Can you explain how the turnover rate is calculated in this example?

What is the significance of formatting the turnover rate as a percentage?

Can you show how to handle cases where the headcount might be zero?

close

bookChallenge: Yearly Turnover Analysis

Swipe um das Menü anzuzeigen

You have learned how to use Python lists to store HR data and how to perform calculations using elements from these lists. When analyzing employee turnover, it is common to have two lists: one containing the number of employee departures for each year, and another containing the average headcount for each year. By processing these lists element-wise, you can calculate important HR metrics such as the turnover rate for each year.

1234567
departures_per_year = [8, 10, 7, 12] average_headcount_per_year = [80, 85, 83, 90] years = [2020, 2021, 2022, 2023] for year, departures, headcount in zip(years, departures_per_year, average_headcount_per_year): turnover_rate = departures / headcount print(f"Year: {year} - Turnover Rate: {turnover_rate:.2%}")
copy

When presenting turnover rates, it is helpful to display both the year and the calculated percentage in a clear format. You can use Python's formatted string literals (f-strings) to include the year and format the turnover rate as a percentage with two decimal places. This makes your output easy for stakeholders to read and interpret.

Aufgabe

Swipe to start coding

Write a function that prints the turnover rate for each year using the provided lists: years, departures, and headcounts.

  • For each year, calculate the turnover rate as the number of departures divided by the average headcount.
  • Format the turnover rate as a percentage with two decimal places.
  • Print a line for each year in the format: "Year: - Turnover Rate: %".

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 5
single

single

some-alt