Write a program to calculate the salary as per the following table:
Gender | Year of Service | Qualifications | Salary |
---|---|---|---|
Male | >= 10 | Post - Graduate | 15000 |
>= 10 | Graduate | 10000 | |
< 10 | Post - Graduate | 10000 | |
< 10 | Graduate | 7000 | |
Female | >= 10 | Post - Graduate | 12000 |
>= 10 | Graduate | 9000 | |
< 10 | Post - Graduate | 10000 | |
< 10 | Graduate | 6000 |
This program is a simple Python script that calculates an employee's salary based on their gender, years of service, and level of education. The program prompts the user to enter their gender as 'f' or 'm', years of service as an integer, and level of education as 0 for graduate and 1 for post-graduate.
The program then uses a series of if-elif statements to check the input against different conditions and assigns a salary accordingly. For example, if the gender is 'm' and the years of service are greater than or equal to 10 and the education is a post-graduate, the salary is assigned as 15000. If the gender is 'f' and the years of service are less than 10 and the education is a graduate the salary is assigned as 6000. Finally, the salary is printed out to the user.
gen = input("Enter the Gender f/m :") yos = int(input("Enter the Years of Service :")) qual = int(input("Enter the Qualification (Graduate(0) , Post-Graduate(1)) :")) if(gen=='m' and yos>=10 and qual==1): salary = 15000 print("Salary : " , salary) elif( (gen=='m' and yos>=10 and qual==0) or ( gen=='m' and yos<10 and qual==1 ) or ( gen=='f' and yos<10 and qual==1)): salary = 10000 print("Salary : " , salary) elif( gen=='m' and yos<10 and qual==0): salary = 7000 print("Salary : " , salary) elif( gen=='f' and yos>=10 and qual==1): salary = 12000 print("Salary : " , salary) elif( gen=='f' and yos>=10 and qual==0): salary = 9000 print("Salary : " , salary) elif( gen=='f' and yos<10 and qual==0): salary = 6000 print("Salary : " , salary)
Enter the Gender f/m :m Enter the Years of Service :10 Enter the Qualification (Graduate(0) , Post-Graduate(1)) :0 Salary : 10000
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions