mercredi 30 août 2017

Combining the results of two if statements - python / jupyter notebook

I have a bit of code that calculates pay / overtime pay based on the hours worked in a week. There are two if statements that calculate the pay for week1 and week2. What I am trying to do is then calculate the total pay which is the pay for the results of the week1 if statement plus the results of the week2 if statement, but I'm struggling. I'm probably making this much more difficult than it needs to be.

I'm using a Jupyter Notebook where each of the chunks below are in a separate cell. The results of the first if statement = 440 the second if statement = 473. The desired result is to combine these so that the output is 913.

Any help or suggestions are greatly appreciated!

rate = 11
week1 = 40 
week2 = 42

if week1 <= 40:
    print((rate * week1))
else:
    print((week1 - 40)*(rate * 1.5) + (40 * rate))

if week2 <= 40:
    print(rate * week2)
else:
    print((week2 - 40)*(rate * 1.5) + (40 * rate))

Aucun commentaire:

Enregistrer un commentaire