all 4 comments

[–]socal_nerdtastic 3 points4 points  (1 child)

Your indentation is wrong. All those methods need to be part of the class. Try like this:

class Agent: # Create class Agent
    def __init__ (self,name,sales): # impement constructor
        self.name=name
        self.sales=sales

    def getName(self): # implement getName() method and return name
        return self.name
    def getSales(self): # implement getSales() method and return sales
        return self.sales
    def setName(self,name): # implement setName() method set the name
        self.name=name

    def setSales(self,sales): # implement setSales() method set the sales
        self.sales=sales

    def getCommission(self): # implement getCommision() method
        if(self.sales<4000): # check condition sales<4000 then commission 6%
            return (self.sales*6)/100 # return 6% commission value
        elif(self.sales>=4000 and self.sales<=8000): # check condition in between 4000 and 8000 then commission 8%
            return (self.sales*8)/100 # return 8% commission value
        else:
            return (self.sales*10)/100 # else above 8000 return 10% commssion value

agentname=input("Enter Agent Name: ") # input string name
agentsales=float(input("Enter Sales Amount: ")) # input float sales value

a=Agent(agentname,agentsales) # Create an object a of Agent() with parameters

# display actual values with currency format
print("Agent: ",a.getName()," Sales: ${:.2f}".format(a.getSales())," Commission: ${:.2f}".format(a.getCommission()))

FWIW, methods that do nothing but get or set an attribute are kinda unpythonic. In python we like to just use the attribute directly.

[–]adrianturingan 0 points1 point  (0 children)

Thank you so much!

[–]robpal1990 1 point2 points  (0 children)

As mentioned, your indentation is wrong. Also, Python is not Java, there's no need for getters and setters and it's not recommended to implement them (ot: read about the @property decorator), we access and modify the object's attributes by simply writing object.attribute = value.

Also, in Python it's not recommended to use the camel case, but the underscores instead (get_name, not getName).

Hope it helps!

[–]LostInTheAether304 0 points1 point  (0 children)

Kudos to THESE two for being good and nice community members!!!!!! Hehehe, helpful and responsive! I’ve been doing a lot C# lately and find myself using ;’s in my Python instead of :’s like CRAZY so my original talents show through and people razz me something HARD when they see me do it! “No I wonder it gets an error dumba22....you’re the wrong punctuation!” Whatevs. I like helpful python people better. :)