Let’s assume that you want to find the difference between 2
numbers. As you probably remember from school, the difference
is not commutative, meaning that:
Dictionaries represent a commonly used data structure in many
scenarios. You may also have cases when you need to merge 2
dictionaries, for example, given that we have 2 equal keys, we
want to get the value of the second dictionary.
One of the most common ways to introduce someone to
programming is by starting with printing
Hello World and then showing them how to do math
operations using simple coding instructions.
Lists are pretty much widely used throughout every project
that you can think of. Tuples, on the other hand, are not that
common, but both of them have something in common that you can
use right away.
You can use the same method for both of them to find indexes
of certain elements.
You have been doing math calculations since a very young age,
from adding two numbers, to multiplying, dividing, and finding
the square root of a number by hand.
In Python, you can also multiply a string with a number.
Yes, you read that right. You do not have to do something big,
or fancy: You can just take a string and multiply it with any
natural number.
You may be wondering,
“What’s the result? I know what is 3 * 3, but I don’t know
what’s going to be the result of 3 * ‘abc’?”
Lists represent one of the most used data structures in any
Python script. One of the reasons why I like programming in
Python is that I get to reach a result quite quickly.
One such thing is the opportunity to easily and quite simply
access their elements quite flexibly.
With flexibility, I mean, having the opportunity to choose
only the elements that we want.
One of the main uses of methods in any programming language is
the opportunity to simply implement a functionality once and
then use it as many times as you need.
In a lot of cases, you are supposed to call these functions
with actual parameters that are then expected to be used
inside the method.