by Suf | Dec 21, 2021 | Programming, Python, Tips
The square of a number results from multiplying a number by itself. The square of the number is the same as raising the number to the power of two. For example $latex 8 \times 8 = 64$, which is equal to $latex 8^{2}$ as well. The square of real numbers is always...
by Suf | Dec 21, 2021 | Programming, Python, Tips
In Python, a dictionary is stores data in key:value pairs. Python 3.7 dictionaries are ordered data collections; in Python 3.6 and previous dictionaries are unordered. You cannot perform a slice on a Python dictionary like a list. Dictionaries can have custom key...
by Suf | Dec 21, 2021 | Programming, Python, Tips
Integers and iterables are distinct objects in Python. An integer stores a whole number value, and an iterable is an object capable of returning elements one at a time, for example, a list. If you try to iterate over an integer value, you will raise the error...
by Suf | Dec 20, 2021 | Programming, Python, Tips
In Python, we index lists with numbers. To access an item from a list, you must refer to its index position using square brackets []. Using a tuple instead of a number as a list index value will raise the error “TypeError: list indices must be integers, not...
by Suf | Dec 19, 2021 | Programming, Python, Tips
A Python dictionary is a collection of data values stored in key-value pairs. To access items in a dictionary, you must use the indexing syntax of square brackets [] with the index position. If you use parentheses, you will raise the “TypeError:...