how do you write a command that turn left or right at an angle in a superclass is it like this:

def left(self): self.position += self.angle return (self.position)


its part of Object oriented Python

Recommended Answers

All 3 Replies

Could you reword your question a little better? maybe give an example of what your looking for, and any code your have allready tried and failed with?

Its tough to understand can you please post your doubt or question clearly....to post our replies.

Let's assume you have something like this ...

class Turn:
    def __init__(self, angle=10, position=0):
        self.angle = angle
        self.position = position

    def left(self):
        self.position += self.angle 
        return (self.position)

# creat an instance of the class
turn = Turn()

# now use the left() class method
print turn.left()  # 10

# again
print turn.left()  # 20
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.