105k views
5 votes
write a python program to input employee salary and number of days worked from user and find basic pay,DA,HRA,PFand net pay .

User HefferWolf
by
7.9k points

1 Answer

4 votes

Final answer:

The Python program calculates an employee's salary components by taking the total salary and the number of days worked as input. It computes the basic pay, Dearness Allowance (DA), House Rent Allowance (HRA), Provident Fund (PF), and finally, the net pay.

Step-by-step explanation:

To write a Python program that calculates an employee's salary components, you'll need to interact with the user to input the employee's salary and the number of days they have worked. Using these inputs, the program can calculate basic pay, Dearness Allowance (DA), House Rent Allowance (HRA), Provident Fund (PF), and net pay. Here is an example of how the program could be written:

# Input the salary and days worked
total_salary = float(input('Enter the total salary: '))
days_worked = int(input('Enter the number of days worked: '))

# Constants for percentages
da_percent = 0.05 # Dearness Allowance
hra_percent = 0.1 # House Rent Allowance
pf_percent = 0.12 # Provident Fund

# Calculations
basic_pay = total_salary / 30 * days_worked
DA = basic_pay * da_percent
HRA = basic_pay * hra_percent
PF = basic_pay * pf_percent
net_pay = basic_pay + DA + HRA - PF

# Output
print(f'Basic Pay: {basic_pay}')
print(f'Dearness Allowance (DA): {DA}')
print(f'House Rent Allowance (HRA): {HRA}')
print(f'Provident Fund (PF): {PF}')
print(f'Net Pay: {net_pay}')

Please note that the DA, HRA, and PF percentages are assumed for the sake of this example and would be replaced by the actual percentages as per the company's policy. The calculation of the basic pay assumes there are 30 days in a month.

User Tomek Tarczynski
by
7.7k points