troubleshooting Question

Python compiler throwing an error while executing the program ca not defined

Avatar of sam_2012
sam_2012 asked on
4 Comments1 Solution114 ViewsLast Modified:
Hi Team,

Iam trying to run the below code in python , Iam getting an error while calculating the ca value .Kindly help me with the casue of the error
''' write a program to calulate the gross salary of the employee
if his basic salary less than 2000 then HRA 10% of basic salary
DA 90% of basic salary , ca=10
> 2000 , hra 5%  bs and da 20 percent of basic salary '''

basicSalary=int(input("Enter the basic salary"))
if basicSalary < 2000:
      hra=basicSalary * 0.1
      da=basicSalary * 0.9
      hra=basicSalary * 0.05
      da=basicSalary * 0.2

print (" the gross salary of employees is ",grossSalary)

Enter the basic salary2300
Traceback (most recent call last):
  File "", line 15, in <module>
NameError: name 'ca' is not defined
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros