Python function: overtime error creating salary function

I'm currently trying to create a pay function using python 3.50, which looks like this: the user enters the hourly payment as "x" and the hours as "y". I am trying to implement part of the overtime work, where if the hours worked exceed 40 people, 1.5 times more is paid during these extra hours. I enter the wage (10.45) and return 525, when I obviously should return 475, can someone help me choose my mistake? Help will be greatly appreciated, thanks for your time in advance.

def wage(x, y):

    if y > 40:

        ehours = y - 40
        overtime = x * 1.5 * ehours
        return x * y + overtime

    else:
        return x * y
+4
source share
1 answer

, 0,5 ( 1,5 ), :

def wage(x, y):
  if y > 40:
      ehours = y - 40
      overtime = x * 0.5 * ehours
      return x * y + overtime
  else:
      return x * y

, ( ) :

def wage(x, y):
    return x * y + (0.5*x*max(y-40, 0))
+2

Source: https://habr.com/ru/post/1611060/


All Articles