Python __iadd__() Magic Method

Syntax object.__iadd__(self, other) The Python __iadd__() magic method implements in-place addition x += y that adds together the operands and assigns the result to the left operand. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to the first operand. When you call x += y, … Read more

Python Excel – Styling Your Worksheets

Part 6 in Working with Excel focuses on styling. Impress your customers by styling the Worksheet to match their brand by: adding in their unique logo, using their color scheme, using their preferred font style, formatting the Worksheet using their preferred report style. Taking the time to do this makes you stand above the crowd. … Read more

Python __rrshift__() Magic Method

Syntax object.__rrshift__(self, other) The Python __rrshift__() method implements the reverse bitwise right-shift operation with reflected, swapped operands. So, when you call x >> y, Python attempts to call x.__rshift__(y). If the method is not implemented, Python attempts to call y.__rrshift__(x) on the right operand and if this isn’t implemented either, it raises a TypeError. The … Read more

Python __rlshift__() Magic Method

Syntax object.__rlshift__(self, other) The Python __rlshift__() method implements the reverse bitwise left-shift operation with reflected, swapped operands. So, when you call x << y, Python attempts to call x.__lshift__(y). If the method is not implemented, Python attempts to call y.__rlshift__(x) on the right operand and if this isn’t implemented either, it raises a TypeError. The … Read more

Python Excel – Sum, Average, Max, and Date Formulas

Part 5 in the Working with Excel series focuses on formulas.   Background After completing Part 4 of this series, you should be comfortable using Python and openpyxl to: add worksheets rename worksheets reorder worksheets delete Worksheets The j-greats.xlsx file should exist on your system.  If you do not have this particular file, click here … Read more

[Google Interview] The 3 Sum Problem

Company Tags: Google, Adobe, Amazon, Apple, Bloomberg, Facebook, Oracle, Microsoft, Tesla Problem Statement Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Note: that the solution set must not contain duplicate triplets. … Read more

Python __rpow__() Magic Method

Syntax object.__rpow__(self, other) The Python __rpow__() method implements the reverse exponentiation operation that is exponentiation with reflected, swapped operands. So, when you call x ** y, Python attempts to call x.__pow__(y). Only if the method is not implemented on the left operand, Python attempts to call __rpow__ on the right operand and if this isn’t … Read more

Python Excel – Basic Worksheet Operations

Part 4 in the Working with Excel series focuses on Worksheet(s) manipulation.   Background After completing Part 3 of this series, you should be comfortable using Python and openpyxl to: append row(s), modify data, insert column(s), delete row(s) and column(s) The j-greats.xlsx file should exist on your system. If you do not have this particular … Read more

Python __rdivmod__() Magic Method

Syntax object.__rdivmod__(self, other) The Python __rdivmod__() method implements the divmod() built-in function with reflected, swapped operands. So, when you call divmod(x, y), Python attempts to call x.__divmod__(y). If the method is not implemented, Python attempts to call __rdivmod__ on the right operand. Only if this isn’t implemented either, it raises a TypeError. We call this … Read more