The above video guides you to how to make Salary calculator using Python
In the first part you will build the exercise based on the theory. In the second part, you will be working on the Salary Calculator project
Checkout the video for more detailed guidance
In order to solve this project, we have to know some basics about finance and statistics that are required to work on this exercise. Let us go through them
What is income?
“Income is the amount of money that is earned either by any person or company for doing a particular job within a specified duration of time”
Income categories:
Wage: Wage is the amount of money that is given to the employees on a daily basis.
Salary: A particular amount of the money that is paid to the employee by the employer on an annual basis is called salary.
Working days In a year:
In a normal year that comprises 365 days, there are 52 weeks. The standard number of hours per day are 8, which gives us the weekly working hours as 40. So according to this, we have:
Total working hours in a year = 52 * 40
Total working hours in a year = 2080
Now if you work for 7.5 hours daily, then we have:
Total working hours in a year = 52 * 37.5
Total working hours in a year = 1950
How is salary calculated?
If we talk about the standard work week, an employee works for almost 40 hours per week.
Hourly:
If you work for 40 hours per week:
Hourly salary = Annual Salary / 2080
Daily:
If you work for 8 hours per day:
Daily salary = Hourly salary * 8
Weekly:
If you want to calculate weekly pay by using annual salary, subject to the formula below:
Weekly salary = Annual Salary / 52
Monthly:
Subject to the equation below to calculate your monthly pay:
Monthly Salary = Gross Annual Salary / 12
Annually:
Here we will calculate annual income from the various methods as below: From monthly:
Annual Salary = Monthly Salary * 12
Exercise -1: Salary calculator
# constant values
year = 365
weeks = 52
# values to insert
name = input('What is your Full name ? : ')
hours_per_day = int(input('how many hours you work per day ? : '))
Working_Days = int(input('how many days you work per week ? : '))
Annual_Salary = float(input('What is your Annual Salary ? : '))
# So according to this, we have:
weekly_working_hours = hours_per_day * Working_Days
Total_working_hours_in_a_year = weeks * weekly_working_hours
# Hourly Salary
Hourly_salary = Annual_Salary / Total_working_hours_in_a_year
# Daily Salary:
Daily_salary = Hourly_salary * 8
# Weekly Salary:
Weekly_salary = Annual_Salary / 52
'''# to determine weekly pay by using number of hours you work in a week
Weekly_salary = Working_Days * hours_per_day'''
# Monthly Salary:
Monthly_Salary = Annual_Salary / 12
# Annually Salary:
# to calculate annual income from monthly salary:
Annual_Salary = Monthly_Salary * 12
print("\n================ employee information =======================\n")
print('Name: ' + name)
print('Working hours per day: ' + str(hours_per_day))
print('Working days per week: ' + str(Working_Days))
print("\n================ salary information ===========================\n")
print('Hourly Salary: R${:,.2f}'.format(Hourly_salary))
print('Daily Salary: R${:,.2f}'.format(Daily_salary ))
print('Weekly Salary: R${:,.2f}'.format(Weekly_salary))
print('Monthly Salary: R${:,.2f}'.format(Monthly_Salary))
print('Total gross pay: R${:,.2f}'.format(Annual_Salary))
print("\n=====================================================================")
Output:
What is your Full name ? : Lucky
how many hours you work per day ? : 8
how many days you work per week ? : 5
What is your Annual Salary ? : 100000
================ employee information =======================
Name: Lucky
Working hours per day: 8
Working days per week: 5
================ salary information ===========================
Hourly Salary: R$48.08
Daily Salary: R$384.62
Weekly Salary: R$1,923.08
Monthly Salary: R$8,333.33
Total gross pay: R$100,000.00
=====================================================================
Go to next blog, If you like the exercise and want to build project of salary calculator using python
Happy learning!
Copyright Notice: Unless otherwise indicated, all articles are original to this site, and reproduction must cite the source
Article link:http://pybeginners.com/article/how-to-make-a-salary-calculator-in-python/