Example HTML page

A Python program of pay computation to give the employee 1.5 times the hourly rate for hours worked above 50 hours

In this post I am writing a python program that prints pay computation.

Sample Input1:
Enter no. of hours : 55
Enter rate: 10
Expected Output:575.0

Sample Input2:
Enter no. of hours : 45
Enter rate: 10
Expected Output:450.0

hrs = int(input("Enter no. of hours: "))
rate = int(input("Enter rate:"))
if hrs > 50:
    overtime = hrs - 50
    pay = (50 * rate)+(overtime * rate * 1.5)
    pay = hrs * rate


Accepting integer number of hours from the user and stores in a ‘hrs’ variable. Accepting rate from the users and stores in ‘rate’ variable.
By checking the condition using ‘if’ statement, if hrs > 50 is True then calculates ‘overtime’
overtime = hrs – 50
and calculates pay as shown below, if hrs >50, till 50hrs rate will be 10 and for rest of the hrs 10 * 1.5
pay = (50 * rate )+(overtime * rate * 1.5)
or else pay will be regular rate as below
pay = hrs * rate

#Output 1:

Enter no. of hours: 55
Enter rate:10
Pay: 575.0

#Output 2:

Enter no. of hours: 45
Enter rate:10
Pay: 450

If you have any queries please feel free to contact satish.raju45@gmail.com

Example HTML page

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest