Write a program to solve a simple payroll calculation in python – Python Program to Enter Basic Salary and Calculate Gross Salary of an Employee

Write a program to solve a simple payroll calculation in python: In the previous article, we have discussed Python Program to Check Duck Number
Gross Salary:

It denotes the amount paid out to an individual prior to any voluntary or mandatory deductions. As a result, it is the total pay received by an employee before taxes and other deductions. Gross salary includes all sources of income and is not limited to only cash income. As a result, it includes any benefits or services received by an employee. The salary that an employee receives, on the other hand, is the net salary after deductions. Python Program For Employee Salary Calculation. These are explained below for foundation concept to learn.

  • Basic Salary Calculation, Python Program For Salary Calculation, Gross Salary Program In Python
  • Python Program To Calculate Salary Of An Employee.
  • Employee Salary Calculation Program In Python Using Class.
  • Python Program To Calculate Net Salary.
  • Python Program To Calculate Net Salary.
  • Gross Salary In Python.
  • Basic And Gross Salary.
  • Gross Salary Basic Salary.
  • Gross Salary Formula.
  • Python Salary Program.

House rent allowance (HRA):

House rent allowance, or HRA, is a salary component that covers employees’ housing expenses.

Formula to calculate the Gross Salary :

Gross salary equals the sum of the basic salary plus the HRA and any other allowances.

Gross salary = Basic salary + House Rent Allowance + Other Allowances

Gross salary =basic + da + hr + da_on_ta

da=(15*basic)/100

hr=(10*basic)/100

da on ta=(3*basic)/100

Examples:

Example1:

Input:

Given Basic salary = 23000

Output:

The Employee's Gross salary from the given basic salary { 23000 } = 29440.0

Example2:

Input:

Given Basic salary = 18000

Output:

The Employee's Gross salary from the given basic salary { 18000 } = 23040.0

Program to Enter Basic Salary and Calculate Gross Salary of an Employee  in Python

Below are the ways to calculate the Gross salary from the given basic salary :

Python Program To Calculate Employee Salary

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Give the basic salary as static input and store it in a variable.
  • Calculate the value of da from the above given mathematical formula and store it in another variable.
  • Calculate the value of hr from the above given mathematical formula and store it in another variable.
  • Calculate the value of da-on-ta from the above given mathematical formula and store it in another variable.
  • Calculate the gross salary using the above given mathematical formula and store it in another variable.
  • Print the Gross salary of an employee from the given basic salary.
  • The Exit of the program.

Below is the implementation of the above given approach:

# Give the basic salary as static input and store it in a variable.
gvn_basc_sal = 23000
# Calculate the value of da from the above given mathematical formula and store
# it in another variable.
gvn_da = (float)(15 * gvn_basc_sal) / 100.0
# Calculate the value of hr from the above given mathematical formula and store
# it in another variable.
gvn_hr = (float)(10 * gvn_basc_sal) / 100.0
# Calculate the value of da-on-ta from the above given mathematical formula and store
# it in another variable.
gvn_da_on_ta = (float)(3 * gvn_basc_sal) / 100.0
# Calculate the gross salary using the above given mathematical formula and store
# it in another variable.
gros_sal = gvn_basc_sal + gvn_da + gvn_hr + gvn_da_on_ta
# Print the Gross salary of an employee from the given basic salary.
print(
    "The Employee's Gross salary from the given basic salary {", gvn_basc_sal, "} =", gros_sal)

Output:

The Employee's Gross salary from the given basic salary { 23000 } = 29440.0

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Give the basic salary as user input using the float(input()) function and store it in a variable.
  • Calculate the value of da from the above given mathematical formula and store it in another variable.
  • Calculate the value of hr from the above given mathematical formula and store it in another variable.
  • Calculate the value of da-on-ta from the above given mathematical formula and store it in another variable.
  • Calculate the gross salary from the above given mathematical formula and store it in another variable.
  • Print the Gross salary of an employee from the given basic salary.
  • The Exit of the program.

Below is the implementation:

# Give the basic salary as user input using the float(input()) function and
# store it in a variable.
gvn_basc_sal = float(input("Enter some random Number = "))
# Calculate the value of da from the above given mathematical formula and store
# it in another variable.
gvn_da = (float)(15 * gvn_basc_sal) / 100.0
# Calculate the value of hr from the above given mathematical formula and store
# it in another variable.
gvn_hr = (float)(10 * gvn_basc_sal) / 100.0
# Calculate the value of da-on-ta from the above given mathematical formula and store
# it in another variable.
gvn_da_on_ta = (float)(3 * gvn_basc_sal) / 100.0
# Calculate the gross salary using the above given mathematical formula and store
# it in another variable.
gros_sal = gvn_basc_sal + gvn_da + gvn_hr + gvn_da_on_ta
# Print the Gross salary of an employee from the given basic salary.
print(
    "The Employee's Gross salary from the given basic salary {", gvn_basc_sal, "} =", gros_sal)

Output:

Enter some random Number = 50000
The Employee's Gross salary from the given basic salary { 50000.0 } = 64000.0

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Read also:

  1. Calculate Gross Salary In Python?
  2. What Is Basic And Gross Salary?
  3. Difference Between Gross Salary And Basic Salary?
  4. Calculating Gross Salary?
  5. How To Calculate Gross Salary?
  6. How To Calculate Gross Salary From Basic Salary?
  7. Write A Program To Calculate Net Salary After Inputting Basic Salary Hra + Da And Tax In Python
  8. Calculate Gross Salary In Python?

Related Posts On: