Python 3

Classroom Training Courses

The goal of this website is to provide educational material,
allowing you to learn Python on your own.
Nevertheless, it is faster and more efficient to attend a "real"
Python course in a classroom, with
an experienced trainer. So why not attend one of the live
Python courses in Strasbourg, Paris, Luxembourg, Amsterdam, Zürich / Zurich, Vienna / Wien, London, Berlin, Munich, Hamburg, Frankfurt
or Lake Constance by Bernd Klein, the author of this tutorial?

This way you will get a perfect training up to your needs and it will be extremely cost efficient as well.
Contact us so we can define and find the best course curriculum to meet your needs, and schedule course sessions to be held at your location.

Skilled Python Programmers

You are looking for experienced Python developers or programmers? We can help you, please
contact us.

Quote of the Day:

"The difference between stupidity and genius is that genius has its limits" (Albert Einstein)

Sets and Frozensets

Introduction

In this chapter of our tutorial, we are dealing with Python's implementation of sets. Though
sets are nowadays an integral part of modern mathematics, this has not always been like this. The
set theory had been rejected by many, even great thinkers. One of them was the philosopher Wittgenstein.
He didn't like the set theory and complained mathematics is "ridden
through and through with the pernicious idioms of set theory...".
He dismissed the set theory as "utter nonsense", as being "laughable" and "wrong". His criticism
appeared years after the death of the German mathematician Georg Cantor, the founder of the set
theory.
David Hilbert defended it from its critics by famously declaring: "No one shall expel us from
the Paradise that Cantor has created.

Cantor defined a set at the beginning of his "Beiträge zur Begründung der transfiniten
Mengenlehre":
"A set is a gathering together into a whole of definite, distinct objects of our perception
and of our thought - which are called elements of the set."
Nowadays, we can say in "plain" English: A set is a well defined collection of objects.

The elements or members of a set can be anything: numbers, characters, words, names,
letters of the alphabet, even other sets, and so on.
Sets are usually denoted with capital letters. This is not the exact mathematical
definition, but it is good enough for the following.

The data type "set", which is a collection type, has been part of Python since
version 2.4. A set contains an unordered collection of unique and immutable objects.
The set data type is, as the name implies, a Python implementation of the sets as
they are known from mathematics. This explains, why sets unlike lists or tuples can't
have multiple occurrences of the same element.

Sets

If we want to create a set, we can call the built-in set function with a sequence or
another iterable object:

In the following example, a string is singularized into its characters to build the resulting
set x: