Multi-Criteria Employee Bonus Eligibility

Hard ⏱ 18 min 24% acceptance ★★★★☆ 4.2
Write a function bonus_amount(years_of_service, performance_rating, is_probation) that computes a bonus. Employees on probation get 0. Otherwise: performance_rating of 5 gives a 15% bonus if years_of_service >= 3, else 10%. performance_rating of 4 gives 10% if years_of_service >= 3, else 5%. performance_rating of 3 or below gives 0%. The function returns the bonus percentage as an integer (e.g. 15, not 0.15).

Examples

Example 1
Input
bonus_amount(4, 5, False)
Output
15
Explanation

Top rating with 3+ years of service.

Example 2
Input
bonus_amount(1, 5, False)
Output
10
Explanation

Top rating but under 3 years.

Example 3
Input
bonus_amount(10, 5, True)
Output
0
Explanation

On probation, so no bonus regardless of other factors.

Example 4
Input
bonus_amount(5, 3, False)
Output
0
Explanation

Rating of 3 or below never qualifies.

Constraints

  • years_of_service is a non-negative integer.
  • performance_rating is an integer from 1 to 5.
  • is_probation is a boolean.

Topics

Conditional StatementsBusiness Logicnested conditionals

Companies

InfosysWiproHCLTech

Hints

Hint 1

The probation guard clause should be checked first and short-circuit everything else.

Hint 2

Nest a years_of_service check inside each of the rating==5 and rating==4 branches.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.