Q:

How to create a class with get and set methods?

I want to create a class myCalc that has a constructor, with get and set methods and uses a property. I understand the get and set methods but am having trouble with putting all of the pieces together so it performs what I want it to do. What I have so far is this:
class myCalc(object):

    def __init__(self):
            self._ =name

        def (self):
            """Get the answer doubled."""
            return self._plus

        def (self):
            """Get the answer squared."""
            return self._times

I'd like to get as far as having the program respond with properties that double and square the number in the object. Any suggestions would be helpful.

A:

A property object has getter, setter, and deleter methods
You should use decorators as follows:
class C(object):
    def __init__(self):
        self._x = None

    @property
    def x(self):
        """I'm the 'x' property."""
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

    @x.deleter
    def x(self):
        del self._x

If you want it readonly, just use @property and remove the two others

