Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Anniversary Notification Script | Reporting and Insights for HR
Python for HR Specialists

bookChallenge: Anniversary Notification Script

You have already learned how to parse dates from strings and compare date components to automate HR notifications. When employee hire dates are stored as strings in the YYYY-MM-DD format, you can extract the month portion to check for work anniversaries. This is an essential skill for creating scripts that help HR teams celebrate employee milestones and foster engagement.

1234
# Extracting the month from a date string in 'YYYY-MM-DD' format hire_date = "2019-07-15" month = hire_date[5:7] # This gets the substring representing the month print("Month:", month)
copy

When creating notification messages, make sure they are clear and easy to understand. Include the employee's name and the number of years they have been with the company. This helps personalize the message and ensures the recipient understands the purpose of the notification.

Завдання

Swipe to start coding

Write a function that prints a notification for each employee whose work anniversary falls in the given month. Use the list of employee dictionaries provided, where each dictionary contains the employee's name and hire date in 'YYYY-MM-DD' format.

  • For each employee, check if the month in their hire_date matches current_month.
  • If it matches, calculate how many years they have been with the company as of current_year.
  • Print a message that includes the employee's name and the number of years they have been with the company.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 7
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

How can I calculate the number of years an employee has been with the company?

Can you show me how to include the employee's name in the notification message?

What is the best way to format a personalized work anniversary message?

close

bookChallenge: Anniversary Notification Script

Свайпніть щоб показати меню

You have already learned how to parse dates from strings and compare date components to automate HR notifications. When employee hire dates are stored as strings in the YYYY-MM-DD format, you can extract the month portion to check for work anniversaries. This is an essential skill for creating scripts that help HR teams celebrate employee milestones and foster engagement.

1234
# Extracting the month from a date string in 'YYYY-MM-DD' format hire_date = "2019-07-15" month = hire_date[5:7] # This gets the substring representing the month print("Month:", month)
copy

When creating notification messages, make sure they are clear and easy to understand. Include the employee's name and the number of years they have been with the company. This helps personalize the message and ensures the recipient understands the purpose of the notification.

Завдання

Swipe to start coding

Write a function that prints a notification for each employee whose work anniversary falls in the given month. Use the list of employee dictionaries provided, where each dictionary contains the employee's name and hire date in 'YYYY-MM-DD' format.

  • For each employee, check if the month in their hire_date matches current_month.
  • If it matches, calculate how many years they have been with the company as of current_year.
  • Print a message that includes the employee's name and the number of years they have been with the company.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 7
single

single

some-alt