Home » Python » 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 day based on the hours worked**.

Submitted by Shivang Yadav, on March 01, 2021

The payments made to the employee are based on the hours he has worked. Ideal working hours per day is 8 hours and for that 1500 is paid to the employee.

The calculation of salary based on hours worked is,

- Hours worked = 8, payment = 1500.
- Hours worked < 8, pay less, 75 per hour.
- Hours worked > 8, pay more, 75 per hour.

**Python program to calculate gross pay**

workingHours = int(input("Enter Working Hours: ")) if(workingHours == 8): print("1500") elif(workingHours >= 1 and workingHours < 8): lessHours = 8 - workingHours lessPay = ((1500*5)/100)*lessHours totalPay = 1500 - lessPay print("Less Hours:",lessHours) print("Less Payment:", lessPay) print("Total:",totalPay) elif(workingHours > 8 and workingHours <= 14): extraHours = workingHours - 8 extraPay = ((1500*5)/100)*extraHours totalPay=1500 + extraPay print("Extra Hours:",extraHours) print("Extra Payment:", extraPay) print("Total:",totalPay) else: print("Invalid Hours...")

**Output:**

Enter Working Hours: 12 Extra Hours: 4 Extra Payment: 300.0 Total: 1800.0

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions