Overloading arithmetic operators
[latexpage] We've seen that the usual arithmetic operators +, -, * and / can be used with Python's numeric data types, and that some of these operators also have meaning…
[latexpage] We've seen that the usual arithmetic operators +, -, * and / can be used with Python's numeric data types, and that some of these operators also have meaning…
[latexpage] One of the cornerstones of OOP is the concept of inheritance. The idea is best illustrated with an example. Suppose we have a number of objects that all have…
Programmers used to other object oriented languages such as C++, C# or Java will be familiar with the idea of private data fields and methods within a class. These private fields…
Although nothing we've done so far might suggest it, Python is actually a fully object-oriented language. Pretty well everything in a Python program is implemented as an object. From primitive…
A string in Python is a sequence of Unicode characters. Defining strings A string can be defined as an immutable object by giving the character sequence between a pair of…
[latexpage] We've seen how to define a function using the def keyword. This is the standard method of function definition in any case where more than a single expression is…
In our first post on Python functions, we saw how to define a simple function and pass arguments to it. Python offers a lot of flexibility in how arguments can…
Once your program gets larger than a few lines, it's good practice to modularize the code. This means you should analyze the program structure to identify specific, relatively simple, blocks.…
A Python dictionary is an implementation of what you may know as a hash table or associative array. A dictionary consists of a collection of key-value pairs. When you query…
The set data type in Python implements most of the operations from mathematical sets. The most common representation of sets in mathematics uses Venn diagrams (overlapping circles) which I'm assuming…