Python 3 Script to Calculate Gross Salary of Employee From Basic Salary Full Project For Beginners

 

 

 

app.py

 

 

# 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);

Leave a Reply