Overtime Pay from Punch Logs

Medium ⏱ 12 min 46% acceptance ★★★★★ 4.7
Write weekly_pay(hours, rate) where hours is a list of 7 daily work-hours. Regular time is the first 40 hours of the week; everything beyond pays 1.5×. Compute total pay — tracking the crossover mid-day correctly (a week of 5×9 hours crosses 40 during day 5).

Examples

Example 1
Input
weekly_pay([9, 9, 9, 9, 9, 0, 0], 100)
Output
4750.0
Explanation

40 regular hours (4000) + 5 OT hours at 150 (750).

Constraints

  • Weekly 40-hour threshold, not daily.
  • OT multiplier exactly 1.5.

Topics

Business Logicpayroll

Companies

ADPDarwinboxKeka

Hints

Hint 1

total_hours = sum(hours); OT = max(0, total - 40).

Hint 2

Pay = regular×rate + ot×rate×1.5.

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