Python Tutorial
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.
#!/usr/bin/python # function computes the gross salary from basic salary. def calcualte_gross_salary(basic_salary): 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 Enter basic salary: 3400 Gross Salary is: 7630.000000 $ python gross_salary.py Enter basic salary: 2000 Gross Salary is: 4000.000000
Python Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page