×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python program to calculate gross pay (Hourly paid employee)

Here, we are writing a Python program in which we will calculate the total payments made to the employee per week based on the hours worked. By Shivang Yadav Last updated : January 13, 2024

Problem statement

Write a Python program to calculate gross pay of hourly paid employees.

Constraints:

  • Total minimum working hours in a week: 40 hours.
  • Per hour payment: Rs. 300/-
  • Overtime per hour payment: Rs 450/- (regular hourly payment*1.5).

Calculating gross pay of hourly paid employee

An hourly-paid employee gets a fixed amount on an hourly basis. Let's suppose, the hourly payment of an employee is Rs. 300/-, in that case, employee's per day gross pay will be Rs. 2400/- (if he worked for 8 hours).

To calculate gross pay for hourly paid employees, you need to calculate weekly payment based on the working of 40 hours in a week. If someone works overtime, calculate 1.5 times hourly payments for overtime working hours.

Python program to calculate gross pay of hourly paid employee

# Function to calculate weekly payment
# on hourly basis
def weeklyPayment(total_hours, hourly_pay):
    if total_hours > 40:
        result = 40 * hourly_pay + (total_hours - 40) * hourly_pay * 1.5
    else:
        result = total_hours * hourly_pay
    return result

# Main code
hourly_pay = 300

# Input total number of worked hours
hours_worked = int(input("Enter hours: "))

# Gross pay
gross_pay = weeklyPayment(hours_worked, hourly_pay)

print("The gross payment is:", gross_pay)

Output

RUN 1:
Enter hours: 40
The gross payment is: 12000

RUN 2:
Enter hours: 50
The gross payment is: 16500.0

RUN 3:
Enter hours: 25
The gross payment is: 7500

To understand the above program, you should have the basic knowledge of the following Python topics:

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.