concept operation in category python

appears as: operations, operations, operation, The operations, n operation, The operation
Practices of the Python Pro

This is an excerpt from Manning's book Practices of the Python Pro.

The list data type in Python exhibits mainly O(n) operations; determining membership in a list or adding a new item to an arbitrary location in a list is slower for lists with more elements. Adding or removing from the end of a list takes O(1) time. Lists are useful when the items being stored aren’t uniquely identifiable.

yield works a lot like Python’s return statement, except that you can perform operations after you yield a value. This can be used to set up for the next value you want to produce. The following listing shows approximately how range behaves under the hood. Note the use of the yield keyword and the increment of the current value after yield is used.

Figure 5.3. Integration tests focus on how operations work together.
Hello World! Third Edition

This is an excerpt from Manning's book Hello World! Third Edition.

The correct order is the second one, so the correct answer is 14. In math, there is something called the order of operations that tells you which operators should be done before others, even if they are written down after them.

Get Programming: Learn to code with Python

This is an excerpt from Manning's book Get Programming: Learn to code with Python.

Phone attributes—Rectangular, glossy, black, lights up, 4 in x 2 in, has buttons. Operations—Click buttons, makes noise, throw it, make a call, type an email.

class Queue(object):
    def __init__(self):
        self.queue = []
    def get_queue_elements(self):
        return self.queue.copy()
    def add_one(self, item):
        self.queue.append(item)
    def add_many(self, item, n):
        for i in range(n):
            self.queue.append(item)
    def remove_one(self):
        self.queue.pop(0)
    def remove_many(self, n):
        for i in range(n):
            self.queue.pop(0)
    def size(self):
        return len(self.queue)
    def prettyprint(self):
        for thing in self.queue[::-1]:
            print('|_',thing, '_|')

# testing the class by making objects and doing operations
a = Queue()
a.add_one(3)
a.add_one(1)
a.prettyprint()
a.add_many(6,2)
a.prettyprint()
a.remove_one()
a.prettyprint()
b = Queue()
b.prettyprint()

As with the commands to manipulate case, you write the string you want to do the operation on, then a dot, then the command name, and then the parentheses. For example: "some_string".find(). Note that the empty string, '', is in every string.

Figure 20.4. Black-box view of code that adds, subtracts, multiplies, and divides any two numbers