Classes: definition and constructor
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…
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…
A Python tuple is an ordered, immutable set of data items. By ordered, we mean that the items in a tuple are stored in a definite order, not necessarily that they…
[latexpage] We've seen how to create and manipulate lists in Python. There is a special way of creating a list that is concise and powerful. This is list comprehension. The syntax…
The Python list is a powerful data type with a lot of functionality, so we'll cover it in several posts. Here we start with some of its basic properties. First,…