Gross Salary Program in Python


If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is input through the keyboard write a program to find his gross salary

This program is written in the Python programming language and it is designed to calculate the gross salary of an employee based on their basic salary.

  • It starts by using the "input()" function to accept the basic salary, which is stored in a variable named "bs".
  • The program then uses an if-else statement to check if the basic salary is less than 1500. If the condition is true, then the program calculates the HRA (House Rent Allowance) and DA (Dearness Allowance) by multiplying the basic salary with the appropriate percentage.
  • If the condition is false, the program assigns a fixed value of HRA = 500 and calculates the DA by multiplying the basic salary with the appropriate percentage.
  • The program then calculates the gross salary by adding the basic salary, HRA and DA.
  • Finally, the program prints the gross salary. This program is useful for companies to determine the salary of their employees based on their basic salary.

Source Code

bs = float(input("Enter the Basic Salary :"))
if(bs<1500):
	hra=bs*0.1
	da=bs*0.9
else:
	hra=500
	da=bs*0.98
 
gs=bs + hra + da
print("Gross Salary Rs :", gs)

Output

Enter the Basic Salary :12000
Gross Salary Rs : 24260.0


Example Programs