Tuples
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…
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,…
In addition to the while loop, Python also provides the for loop. Its syntax has the form: for [variable] in [collection of values]: do something for each member of the…
[latexpage] Python has two basic loops: while and for. Of these two, while is probably the simpler, so we'll start with a look at it. The basic syntax of a…
[latexpage] Although Visual Studio 2019 comes with a complete basic Python installation, there are many third-party packages that you may wish to use, so it's useful to know how to…
The if statement For making choices among several alternatives, Python, like most languages, provides the 'if' statement. The 'if' statement is a compound statement, so Python's indentation rules apply. The…
[latexpage] If you are to use Python for anything beyond simple one- or two-line programs, you'll need to use some form of compound statement, such as a conditional (if) statement…
[latexpage] If your background includes mathematics or physics, you've no doubt encountered complex numbers. The basic unit used in complex numbers is the square root of $-1$, denoted in mathematics…
If you're used to languages such as C++, C# or Java, you'll know that in these languages, variables must be declared before they can be used. Declaring a variable in…