top of page

# Net Salary Calculations using Python Python has a capacity to conduct various ranges of calculations. Python is an incredibly powerful calculator. By leveraging the math library, numpy, and scipy, Python typically outperforms pre-programmed calculators. Addition, subtraction, multiplication, division, and exponentiation are core operations.

Using this powerful calculator, python, we will see how to calculate net salary of an individual having different types of deductibles and pension.

The 1st step we are expected to do is creating of objects which can be user defined or calculated. Therefore, let us use input() function to allow entry of Employee name as follows.

```# Insert Name of the Employee using input() function
NAME = input("Employee Name:")```

Output

`Employee Name:Yosef`

Like the above let us declare #Gross-Salary and deductible Pension of the Employee as user defined input. What will be different here is that we should change the salary from string to int to help us in our further calculations. To do so we used type() function of python. The Code will looks like the following.

```# Insert gross salary of the Employee using input() function
#Calculate Pension based on the given gross salary
PENSION = GROSS_SALARY * 0.12```

Output after entering 600 ETB as gross salary.

`Please State your Gross Salary:600`

Finally let us use if…elif …else function and calculate the salary of the employee. When we calculate the net salary in addition to pension tax deductibles should be considered according to predefined salary scale as shown below, pension is 12% of gross salary.

 S.No Salary Range Deductible 1 < = 600 ETB 0 2 601 - 1650 ETB 60 3 1651 - 3200 ETB 142 4 3201 - 5250 ETB 303 5 5251 - 7800 ETB 565 6 7801 - 10900 ETB 955 7 >= 10901 ETB 1500

The python code will look like the following.

```#Define the tax, pension and other deductables by salary range
if GROSS_SALARY <= 600:
Net_Salary = GROSS_SALARY - PENSION
elif GROSS_SALARY >= 601 & GROSS_SALARY <=1650 :
Net_Salary = GROSS_SALARY - 60 - PENSION
elif GROSS_SALARY >= 1651 & GROSS_SALARY <=3200 :
Net_Salary = GROSS_SALARY - 142 - PENSION
elif GROSS_SALARY >= 3201 & GROSS_SALARY <=5250 :
Net_Salary = GROSS_SALARY - 303 - PENSION
elif GROSS_SALARY >= 5251 & GROSS_SALARY <=7800 :
Net_Salary = GROSS_SALARY - 565 - PENSION
elif GROSS_SALARY >= 7801 & GROSS_SALARY <=10900 :
Net_Salary = GROSS_SALARY - 955 - PENSION
elif GROSS_SALARY >= 10901:
Net_Salary = GROSS_SALARY - 1500 - PENSION
else:
print("Invalid Entry")

print(NAME)
print(GROSS_SALARY)
print(PENSION)
print(Net_Salary)```

The Output

```Yosef
600
72.0
528.0```

Thank you.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7948863,"math_prob":0.98059464,"size":2653,"snap":"2023-40-2023-50","text_gpt3_token_len":740,"char_repetition_ratio":0.18573046,"word_repetition_ratio":0.03521127,"special_character_ratio":0.28910667,"punctuation_ratio":0.1,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9858206,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-01T12:43:18Z\",\"WARC-Record-ID\":\"<urn:uuid:f262d014-d90c-4191-8e85-3c925c653dbe>\",\"Content-Length\":\"1050518\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c9dd6217-ab4a-47a3-9b2a-5cbaef9f45af>\",\"WARC-Concurrent-To\":\"<urn:uuid:dfe912dd-c48b-4f70-acc2-d36558f842f5>\",\"WARC-IP-Address\":\"146.75.37.84\",\"WARC-Target-URI\":\"https://www.datainsightonline.com/post/net-salary-calculations-using-python\",\"WARC-Payload-Digest\":\"sha1:QECZCSBVGRCZDOES6DWYGWB3PUPPQPDI\",\"WARC-Block-Digest\":\"sha1:3N25FNFC6CY76AXFKDK3HWPBRFB4UKNN\",\"WARC-Truncated\":\"length\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510888.64_warc_CC-MAIN-20231001105617-20231001135617-00630.warc.gz\"}"}