Assignment No-1 NPS
Assignment No-1 NPS
01
Title:
To calculate salary of an employee given his basic pay (take as input from user). Calculate
salary of employee. Let HRA be 10 % of basic pay and TA be 5% of basic pay. Let employee
pay professional tax as 2% of total salary. Calculate salary payable after deductions.
Objective:
Problem Statement:
Outcomes:
1 Students will be able to demonstrate calculations of employee salary.
2 Students will be able to demonstrate different Operator & formulas.
3 Students will be able to demonstrate different Operations on Available data of employee
salary.
Theory:
Python Basics:
Python is an interpreted, high-level, general-purpose programming language. Created by
Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code
readability with its notable use of significant whitespace.
What is Basic salary?
Basic salary is the base income of an individual. It is a fixed part of one's compensation
package.
A basic salary depends on the employee’s designation and also the industry in which the
employee works.
Basic salary is the amount paid to an employee before any extras are added or taken off, such
as reductions because of salary sacrifice schemes or an increase due to overtime or a bonus.
Allowances, such as internet for home-based workers or contributions to phone usage, would
also be added to the basic salary.
Gross salary:
Gross salary is the amount calculated by adding up one's basic salary and allowances, before
deduction of taxes and other deductions. It includes bonuses, over-time pay, holiday pay, and
other differentials.
Gross Salary = Basic Salary + HRA + Other Allowances
Allow
ances:
An allowance is an amount received by the employee for meeting service requirements.
Allowances are provided in addition to the basic salary and vary from company to company.
Some common types of allowances are shown below:
HRA:
HRA received is not fully exempt from tax. HRA that you can claim is the lowest of the
following:
The total amount received as the HRA from the employer in the financial year.
Actual rent paid in the year – 10% of the basic salary in the year.
50% of the annual basic salary if staying in a metro city or 40% of the annual basic
salary if staying in a non-metro city.
Sample Example:
Python program to get employee wages and number of days worked from user and find
Basic Pay, DA, HRA, PF and Net Pay.
(Note HRA, DA and PF are 10%,5%and 12% of basicpay respectively.)
Sample Input 1:
300
30
Sample
Output 1:
Basic
Pay:3000
DA: 150
HRA:300
PF:360
Net Pay: 3090
Solution:
days=float(input("Enter No Days
Present:")) wages=float(input("Enter
wages per Day:")) basic=wages*days;
HRA=basic*0.1;
DA=basic*0.05;
PF=basic*0.12;
netsalary=basic+HRA+D
A-PF;
print("\nBasic:%lf \nHRA:%lf \nDA:%lf \nPF:%lf \nNet Salary:
%lf" % (basic,HRA,DA,PF,netsalary));
This python program is using if else statement to compute the gross salary from basic salary
input. Here we have two different logic's to compute gross salary. so we are using if and else
statements. # function computes the gross salary from basic salary.
def
calcualte_gross_salary(basic_sal
ary): hra = 0;
da = 0;
# salary is less than 2500, hra and da is calculated using this logic, otherwise else
logic. if (basic_salary < 2500):
hra = (basic_salary *
10) / 100; da =
(basic_salary * 90) / 100;
else:
hra = 1000;
da = (basic_salary *
95) / 100; return
(basic_salary + hra + da);
if name == " main ":
# Type casting from input string into float
value. basic_salary = float(input("Enter basic
salary: ")); gross_salary =
calcualte_gross_salary(basic_salary);
print("Gross Salary is: %f" % gross_salary);
Output:
$ python
gross_salary.py
3400
7630.000000
$ python
gross_salary.py Enter
basic salary: 2000
Gross Salary is:
4000.000000
Conclusion:
Thus, we have successfully understood concept of salary calculation formulas and performed
salary calculation in python.