Python Basics Course
Python Basics Course
To get to the contents of each box, you will need to label them. The process is
similar in programming: each variable is given a name.
checkingAccount = 500
savingsAccount = 1000
You have declared two variables here, checkingAccount and savingsAccount , by
storing the values 500 and 1,000, respectively.
You have only used integers here! But it is quite possible to store decimal numbers.
If you store a new value in an existing variable, the type of the variable will change according
to the new value.
Understand Operations Between Variables
As the name suggests, a variable can vary, or rather the value of a variable can
change. You can do this through different operations. Considering the two variables
previously declared in the last example, you could:
+ :addition
- :subtraction
* :multiplication
/ :division
The rules of arithmetic apply in Python, in particular the order of operations, but as in
ordinary mathematics, you can use brackets to rearrange the order of the
calculations. See how to do this in Python:
checkingAccount = checkingAccount - 50
# calculate the number of days to save to reach 5000
Lines starting with a # are comments. They are used to document your code
and help others understand it.
The other lines of code (which can run operations, declarations, etc.)
are expressions. They tell the computer what to do.
Here, each of the expressions assigns a value to a variable. The assignment
operator is = .
1. To the right of the assignment operator is the expression that will
create/calculate a value.
2. To the left of the assignment operator, you write the name of the variable to
which you will assign the corresponding value.
To summarize, to assign a value to a variable, you write an expression. This
expression is built with the name of the variable, followed by the assignment
operator = and finally the value to associate.
There are also other arithmetic operators that are a little more complex, but
nevertheless useful, such as:
# long version
Go Beyond Arithmetic
In the example above, all variables are used to store numerical amounts of money
(integer or decimal).
So far, you have seen that a variable is made up of a name and a value that will
automatically define its type. Yet, to return to your warehouse analogy, one can
imagine that storing money, storing a book, or storing a car require different size
boxes, or even containers. In Python, the storage space of a variable automatically
adapts to its contents, almost by magic!
At this point, it is safe to assume that having only the ‘amount’ value stored in each
of your customer's accounts will probably not be enough. We will most likely also
need their name, their interest rate expressed as a percentage, their address, etc.,
with a new variable for each of these pieces of information. So we would need to
store text in our variables.
interestRate = 1.5
address = "15 19 Bloomsbury Way, Holborn, London, WC1A 2TH"
Note that you need to use double quotes (") to define strings—textual variables—in
Python, otherwise you will get an error! You can however use single (') or
double quotes to declare text variables as seen below:
# equivalent to
address = "15 19 Bloomsbury Way, Holborn, London, WC1A 2TH"
You will go into more detail about the different types of variables in Python in the next
chapters, but for now you have seen three different types of variables:
Integer variables (int)
Decimal variables (float)
Character strings (string)
Let's Recap
In this chapter, you have learned the basics about variables:
The types encountered so far are called primitive types. They exist in Python—a bit
like atoms. These are the simplest types of variables; they are the foundation of all
computer operations and programs. In the same way that atoms can be combined to
make more complex molecules, you can combine primitive types to create much
more complex variable types, as you will see in the next parts of this course. For
now, you will explore numeric types and strings in a little more depth. Let's go!
Numeric Variables
Numeric variables can be broken down into two distinct types:
length = 1876.79
width = 870.0
As long as the associated value is a decimal number, Python will automatically
consider the variable as beingfloat. This is true even if the digit after the decimal
point is a 0, as is the case above with the width variable.
Mix Several Numeric Variables
It is important to keep in mind how the different numeric types can be mixed
together and what the potential consequences are. If you mix different types, the
most complex will be the one kept for the final result. For example, an integer value
can be stored as a float, as seen above with the width variable, but the opposite is
not possible if there are numbers after the decimal point! The float is therefore the
most complex type: if you mix an int with a float , the result will always be a
float , whatever operation is performed or whatever the result is.
a = 7.5
b = 3
c = a/b
print(c)
# this will print 2.5, which is a float
If the result of an operation between two integers is supposed to be a decimal
number, Python will automatically convert it to a float. Moreover, division (even if the
result is supposed to be an integer) will necessarily return a float as well:
a = 10
b = 5
c = a/b
print(c)
# it's a float
However, you can force the conversion of a variable into a well-defined type. This is
called typecasting, because by doing so you are changing (casting) the type of a
variable. To do this, you will need the corresponding functions:
a = 14.0
# a is a float
a = int(a)
print(a)
# a is now an integer: it prints 14 and not 14.0
Try it for Yourself
Try to transform the type of our variable in the following exercise.
Character Strings
You will now explore a little more about character strings, which let you store text in
your variables. First, a bit of semantics: we call them character strings, because
Python does not consider these variables as text, as such, but as a set of characters
put together. This is how you can define character strings in Python (you can use
either single or double quotes):
favorites = "My favorite cities are " + favoriteCityOne + " and "+
favoriteCityTwo
print(favorites) # -> "My favorite cities are San Francisco and New York"
It's much better this way, isn't it? However, you cannot concatenate other types of
variables with strings, such as numeric variables---this would return an error. To
remedy this, you will need to cast your numeric variable to a string, via the str()
function:
city = "Sydney"
numberTrips = 5
history = "I've been to " + city + " " + str(numberTrips) + " times "
print(history) # => "I've been to Sydney 5 times"
You have seen that the operator + can have different purposes depending on the types of
variables you work with:
With numeric types, it is used to add.
With strings, it is used to concatenate.
Let's Recap
In this chapter, you have encountered three primitive types of variables, essential to
all programs/analyses:
Integers (int)
Decimals (float)
Character strings (string)
You have also seen how to use these different types:
Since the beginning of this course, you have used different functions, such as the
print() function of the different cast functions like int() or str() . We will now
take the time to define what a function is, what it is used for and how you can create
your own functions—you are going to find out everything there is to know about
functions!
Discover Functions
During your data analysis, you will regularly have to use groups of statements
several times for a very specific purpose. One of the fundamental principles for any
computer programmer is to get maximum results for minimum effort (there is
even a saying that a good programmer is a lazy programmer!). It is thanks to this
somewhat "lazy" but very effective principle that the idea of functions came about.
Functions can group several statements in a block which will be called using a
name.
Functions are not specific to Python; they are present in all computer languages.
They can:
reuse a portion of code already written just by stating the function name—so
you don't have to rewrite the whole portion of code each time.
simplify code and make it more readable!
There are many pre-existing functions in Python! In addition to those already seen,
there are, for example:
len() :
a function that returns the length of an item. Do you remember
strings? Using this function on a string tells you how many characters the
string contains.
type() : lets you print the type of a variable.
pow(a, b) : lets you calculate a to the power of b. It is equivalent to
writing a**b.
abs() : returns the absolute value of a number.
Here are some examples to illustrate the use of these functions:
def functionName():
# statements
# that can go
# on several
# lines
Note that all the statements associated with your function are offset in the code: this
is called indentation. Python is a block structured language: each group or block of
program must be indented. For example, the set of indented statements following
the : will only be available in functionName . Indentation starts the block, and "de-
indentation" ends it (the first non-indented line will therefore no longer be included in
functionName ).
Indentation is a fundamental principle in Python, which you will encounter many
times in the future. Generally, it translates into four spaces or a tab.
Now define a function that would answer your problem:
def printPerimeter():
dimension1 = 6
dimension2 = 4
dimension3 = 3
print(perimeter)
printPerimeter() # => 13
This function is correct, but not entirely useful: not all of your triangles will have the
exact same dimensions.
In Python, parameters, just like the name of the function, are defined when the
function is written. This is how it would look with the above example:
Parameters are variables declared in a function. The values that are passed as
parameters are called arguments.
perimeter1 = calculatePerimeter(6, 4, 3)
Let's Recap
In this chapter, you have seen that:
It is by observing the common points between different objects that you are able, mentally, to
classify the objects in the same group or category!
For example, there are different types of books, but they all have a title, an author, a back cover, etc.
All books share different attributes that let you classify them in a well-identified category: books.
Let's take a concrete example with a Car class. The plan of a car can be defined by:
So, from this plan, you can create different car models:
etc.
And no matter what the car model, they are all capable of driving or braking, but not with the same
performance!
In summary, a class is the outline of an object, defining its attributes and methods. From the same
class, you can therefore create several objects of the same type, but with different attributes—these
are called class instances.
Focus on Methods
As we said before, in Python, everything is an object. This means that, without knowing it, since the
beginning of this course, you have been manipulating objects! Consider the following lines of code to
illustrate this:
var1 = 14
var2 = 1031
Here, you have declared two variables named var1 and var2 containing the values 14 and 1,031. In
reality, you have created two instances of the int class, two objects each with a single attribute:
its value. The same is true for floats or strings: every time you create a variable of one of these
types, you are actually creating objects in Python with the value you assign to them as an attribute.
Up until now, we have talked about attributes, so now it is time to see what methods are. A class
method is a function that is only available for the instances of this class. If, for example, we consider
the Car class presented above having a drive() method, and a Plane class having a fly() method, you
will agree quite logically that a plane can’t drive, and a car can’t fly. The same goes for our various
objects!
The use of a method is always done via the variableName.method() notation. For
example, strings have a method called lower() which will transform all the text contained in an
object into lower case. Here's how to use it:
In the same way as with functions, class methods can take parameters.
String Methods
During the various data analyses that you will have to perform, you will inevitably be confronted
with textual variables at some point. You have already seen how to change your string to lowercase,
but you may also need to replace some specific words, format the text in a certain way, etc.
Python has implemented many methods to allow us to do all this. Here are the most common ones:
capitalize() : returns the whole text in lowercase with the first letter capitalized.
replace(old, new) : this method takes two arguments: old and new, both of which are
strings. The method returns the original string with all occurrences of old replaced
with new.
find(string) returns either the index of the first occurrence of the string passed in the
argument, or -1 if it does not find it.
As you can see here, especially with the lines concerning the a variable, the methods seen above do
not modify the initial object! They only return the result of the method applied to the object. You
will regularly have to reassign this result to the initial variable, when you want to modify it directly.
Let's Recap
All instances of a class have access to the same methods via the. (dot) notation.
A method, like a function, generally does not modify the initial object.
In the next part, we will see in more detail how to organize your code via different structures and
complex objects.
If you want to analyze several customers at once, you can imagine that you need a
variable for each customer. For the names, this could look like this:
# etc.
If you have 10 customers to analyze, wouldn't it be easier to store them all in a
single variable that would contain all the information?
Lists are ordered objects, i.e., each item of the list is associated with a number
corresponding to its order in the list. This number is called an index and it starts at 0
(not 1!). The first item is therefore associated with index 0, the second with index 1,
etc.
Declaring a list is quite similar to the declaration of any variable seen so far: via
a name to which we associate a list of items to be stored in this name.
For example, here is the list containing the names of four customers:
# assign the value 'Marianne Weaver' to the first name in our list
print(customerName[0])
Python also lets you use negative indices to access or modify an item. The index -1
corresponds to the last item of the list, -2 to the second last, and so on. You can also
access an index range by using the : operator. For example, 1:3 will let you access
items two to four.
print(customerName[-1])
print(customerName[1:3])
print(customerName[:2])
Here you have manipulated lists of strings, but you can do the same thing with the
amount in each individual's account:
print(strangeList[3])
Try it for Yourself
Work with lists yourself in the following exercise.
What should we do now if a new customer is added to our analysis? When I try to do
customerName[4] = '...', it returns an error!
Don't panic! You can't access an index that doesn't already exist in a list in Python...
however, lists have many methods that let you remedy this.
List Methods
Now consider that you want to list animals in order of cuteness (from cutest to "least"
cute). We can easily start with a list of four animals: fox, koala, owl, and otter. These
days, while browsing the internet, you will inevitably come across this image:
This one
deserves a place at the top, right?
And now you want to add the cat to the first position!
The good news for our little cat is that the lists are fully editable, whether it's the
number of items, their order, etc. Thanks to the different list methods, we can:
list = []
list.append(7)
list.append(5)
list = []
list.remove(12) # [4, 5]
list.index(5) # prints 1
Use Dictionaries
Now, let's come back to our problem with the bank's customer names and
associated accounts. With the above method, you would need two lists - a list of
customer names and a list of account balances. Each time a new person is added to
our data, their name and bank account balance would be added to the
corresponding lists.
Dictionaries are another type of object, similar to lists, but which will let you do this
with a single variable! Indeed, a dictionary is a list of items organized via a system
of keys. With a real dictionary, you look up a word to access its definition. In
programming, this word corresponds to the key and the definition to the value
associated with it. This is called a key-value pair. So, we could have:
Each key in a dictionary must be unique. Strings are generally used to define keys,
but this is not a requirement, per se.
Declare a Dictionary
Lists and dictionaries are declared in a similar way, except that a dictionary
uses curly brackets instead of square brackets, and key-value pairs must be
declared:
accounts = {'Marion Weaver': 10000, 'Alberto Mendoza': 150, 'Katharine Tyler': 300,
'Isaac Steele': 1800.74}
len(accounts) # -> 3
Understand Immutable Tuples
The last type of collection we will look at are tuples. These are very similar to lists:
when you want to make sure that data is not modified within a program.
to return several values from a function. Indeed, we didn't address this point
when we talked about functions, but it is possible to return several values...
with a tuple!
to declare several variables in one line.
Declare a Tuple
Tuples are declared in a very similar way to lists, except parentheses are used
instead of square brackets:
a, b = (1, 'apple')
print(a) # -> 1
We will now see how to organize our code via conditional structures.
When you start your program, you do not necessarily know the name of the user in
advance. How about a program that can:
1. Ask the user their name and store their answer in a variable: name .
2. Check that the name variable definitely contains a value (in case the user
doesn't give an answer). The len function will help you to perform this task!
3. If this is the case, say Hello to your user with their name.
4. Otherwise, keep saying Hello to the world.
Here is the corresponding code:
if len(name) > 0:
else:
print("Hello, world!")
It works well! Everything indented below the if is executed if the condition is
true, otherwise the program runs everything indented below the else.
As you can see in the example above, the block construction using the : operator
and indentation are essential and omnipresent concepts in Python! Be very careful
about the organization of your code at this level, to avoid some lines being run when
they should not be, and vice versa.
Let's take a closer look at how the if structure works in practice.
In Python, the boolean can take the values True and False. Now see how to declare
booleans in Python:
thisCourseIsGreat = True
itsAuthorIsVeryHumble = False
Easy, right?
Comparison Operators
As the name suggests, comparison operators are used to compare two values.
There are six main ones:
2 == 2 # -> True
2 == 3 # -> False
4 != 4 # -> False
age=15
if age>=21:
Logical Operators
These operators will let you mix several Boolean values: specific Boolean values or
expression results. There are three of them:
and :
the AND operator.
The final result is true only when all expressions/values are true. For example:
the result of expression1 and expression2 will be True only if expression1
is true AND expression2 is also true.
or : the OR operator.
The final result is true when at least one of the expressions/values is true. For
example: the result of expression1 or expression2 will be at True if
expression1 is true OR expression2 is true.
not : the NOT operator.
This simply reverses the result of the given expression. For example, the
result of not(expression) is true when expression is false.
Here are some examples with the results shown as comments:
not(True) # False
not(False) # True
You can also mix more than two expressions/values:
0 in myList # False
0 in myStringList # False
If the customer has more than $10,000 in their account, they are automatically
approved for their loan.
If they have between $100 and $10,000, we need to manually approve their
application.
Otherwise, the request is denied.
We could use two nested if statements, but Python can link several conditions
thanks to the keyword elif (contraction of else and if). Here is the general form:
if condition1:
# instructions
elif condition2:
# instructions
else:
# instructions
Here is the code corresponding to the example presented above:
print("Loan granted!")
else:
print("Loan refused")
Try it for Yourself
Use conditional structures in the following exercise.
Let's Recap
Conditions let you execute a block of code when a Boolean, variable,
or expression is true (True).
Expressions use Boolean arithmetic, including logical
operators and comparison operators.
You can apply several conditions with if/elif/else chains.
In the next chapter, you will see another way to control the code via loops.
For loops are used when you know in advance how many times an action will be
repeated.
1. You have created a list: myList, containing four items: 7, 2, 4, and 10.
2. The loop will store the first value of the list (in this case 7) in the elt
variable.
3. Then, the whole block of code associated with the for loop (defined via
indentation... again!) is run with elt holding the first value. Here, this block
just involves printing elt.
4. Once this is done, elt will take the second value of the list (in this case 2)
and the block of code is re-run.
5. The loop will continue until all the values in your list have been stored in the
elt variable and the statements for the loop have been executed for each of
them.
Here is a diagram to understand the Python logic behind the loop:
Understand the logic of the loop!
You can also iterate via a string! Remember that strings are also known as
"character strings" because they represent a collection of characters, similar to a list.
myString = "Items"
print(elt)
In this case, elt will successively take each character of your string.
The for Loop via an Iterative Integer Value
Quite often, you will find that you simply need to loop over a range of integer values,
e.g. 0, 1, 2, 3…. This is the conventional loop you see most often in languages like
Javascript or C++. Because Python wants to loop over a collection, you need to
create a collection containing your range of integer values.
To do this, you will use the range(start, stop, step) function, which will
generate a collection of numbers according to three parameters:
start : the first number of the sequence.
stop corresponds to the last number of the sequence, non-inclusive. The
function will generate numbers from start to stop-1.
step : the step between each generated number.
Not all parameters are necessary. For example:
for i in range(5):
while expressionLogic:
# block to execute
It can be interpreted as: as long as my logical expression is true, run the statement
block.
numberTrees = 0
numberTrees += 1
Plant a forest!
With each iteration, the numberTrees is incremented by one. When the variable
reaches the value 10, the expression numberTrees < 10 is no longer true! At this
point, the loop ends and continues running the rest of the program in order. In this
specific case, it prints: "I have a cool forest!"
❗️It is essential to keep in mind that a misused while loop can crash your program!
☠️While the condition is still true, the program remains stuck in a loop. If the
condition never becomes false, the program will never exit the loop. We are in what
is called, in programming, an infinite loop.
Here is an example not to be reproduced at home (this one was made by a
professional...):
theSunIsShining = True
while theSunIsShining:
print("Time to go to sleep!")
This is a common mistake and unfortunately it can happen very easily. So be
careful!
For example, you want to repeat something 10 times, but skip (at least partially)
when the value is 2 or 5. In Python, to force the start of the next loop iteration, use
the keyword continue:
for i in range(10):
print(i)
if (i == 2) or (i == 5):
print("Special case")
continue
if fruit == "orange":
break
Once the fruit has been found in your basket, you finish the loop.
Let's Recap
In this chapter, you have discovered two types of loops:
1. You have created a list: myList, containing four items: 7, 2, 4, and 10.
2. The loop will store the first value of the list (in this case 7) in the elt
variable.
3. Then, the whole block of code associated with the for loop (defined via
indentation... again!) is run with elt holding the first value. Here, this block
just involves printing elt.
4. Once this is done, elt will take the second value of the list (in this case 2)
and the block of code is re-run.
5. The loop will continue until all the values in your list have been stored in the
elt variable and the statements for the loop have been executed for each of
them.
Here is a diagram to understand the Python logic behind the loop:
Understand the logic of the loop!
You can also iterate via a string! Remember that strings are also known as
"character strings" because they represent a collection of characters, similar to a list.
myString = "Items"
print(elt)
In this case, elt will successively take each character of your string.
The for Loop via an Iterative Integer Value
Quite often, you will find that you simply need to loop over a range of integer values,
e.g. 0, 1, 2, 3…. This is the conventional loop you see most often in languages like
Javascript or C++. Because Python wants to loop over a collection, you need to
create a collection containing your range of integer values.
To do this, you will use the range(start, stop, step) function, which will
generate a collection of numbers according to three parameters:
start : the first number of the sequence.
stop corresponds to the last number of the sequence, non-inclusive. The
function will generate numbers from start to stop-1.
step : the step between each generated number.
Not all parameters are necessary. For example:
for i in range(5):
while expressionLogic:
# block to execute
It can be interpreted as: as long as my logical expression is true, run the statement
block.
numberTrees = 0
numberTrees += 1
Plant a forest!
With each iteration, the numberTrees is incremented by one. When the variable
reaches the value 10, the expression numberTrees < 10 is no longer true! At this
point, the loop ends and continues running the rest of the program in order. In this
specific case, it prints: "I have a cool forest!"
❗️It is essential to keep in mind that a misused while loop can crash your program!
☠️While the condition is still true, the program remains stuck in a loop. If the
condition never becomes false, the program will never exit the loop. We are in what
is called, in programming, an infinite loop.
Here is an example not to be reproduced at home (this one was made by a
professional...):
theSunIsShining = True
while theSunIsShining:
print("Time to go to sleep!")
This is a common mistake and unfortunately it can happen very easily. So be
careful!
For example, you want to repeat something 10 times, but skip (at least partially)
when the value is 2 or 5. In Python, to force the start of the next loop iteration, use
the keyword continue:
for i in range(10):
print(i)
if (i == 2) or (i == 5):
print("Special case")
continue
if fruit == "orange":
break
Once the fruit has been found in your basket, you finish the loop.
Let's Recap
In this chapter, you have discovered two types of loops:
#
A Module in Python
A module is a Python file containing a set of predefined and
operational functions, classes, and variables, which you can use as you wish in
your code!
For example, if you are working on a problem involving geometry, you might need:
classes:
o Square—defined by the length of its side
o Triangle—defined by the length of its three sides
o Circle—defined by its radius
o Etc.
variables:
o Pi: constant necessary for calculating the area of a circle, equal to
3.1415...
o Phi: constant that represents the golden ratio, equal to 1.6180...
functions:
o Area: takes as parameter a geometrical object (square, triangle, etc.)
and calculates its area
o Angles: takes a triangle as a parameter, and calculates its internal
angles
o Etc.
You can of course define all these things in your notebook, but that would only make
it more cumbersome. The best is to store all this in an external Python file, which you
will then import into your notebook: it's a module!
'''
Module geometry.py
'''
# variables
pi = 3.14159265359
phi = 1.6180
def area(obj):
if type(obj) == square:
return obj.a**2
class square(object):
def __init__(self,a):
self.a = a
class triangle(object):
def __init__(self,a,b,c):
self.a = a
self.b = b
self.c = c
To import a module, you will need the import keyword. Here is an example with
our geometry module:
import geometry
After doing this, you can use the different items defined in your module:
squa = geometry.square(4)
tri = geometry.triangle(3, 6, 5)
geometry.area(squa) # -> 16
All items included in the geometry module can be used via the moduleName.
notation, i.e., moduleName.function() or moduleName.variable. So, in the above
example, we can use geometry.area() or geometry.pi. If you don't want to
rewrite geometry every time, you have two other options:
Either give an alias to the name of your module, so you only have to write the
alias:
squa = geometry.classes.square(4)
geometry.functions.area(squa) # -> 16
Or, you can also import only one module from the package:
If you want to know more about the packages that let you do these different tasks,
you can take the OpenClassrooms course Use Python Libraries for Data Science,
which goes into more detail about the packages that are most used in data analysis.
To come back to your initial problem (having a square root function), there is for
example the numpy package which offers the necessary function—and many other
things!
import numpy as np
If you are interested in the subject, the different functions of the random module use a very
powerful and popular pseudo-random number generator, called the Mersenne Twister.
Generate Random Numbers
First, import your random module. The name of the package in Python is... random:
import random
The basic function for generating random numbers is called... random() as well (how
original!). It will generate a random float between 0 and 1 (not including 0 or 1).
Let's try a simple example by displaying three random numbers:
Of course, if you run the same code at home, you will get different results (that’s the
nature of randomness)!
But only having a number between 0 and 1 is a bit limited... isn't it?
Absolutely! But the people who created the random package fortunately thought of
everything. There are other functions that let you generate a random number in a
given range:
uniform(a, b) : will generate a random float between a and b .
randint(a, b) : as its name suggests, this one is similar to uniform except
that the random number generated is an integer this time!
You can use one or the other according to your needs!
The normal law is one of the most suitable probability laws to model natural
phenomena resulting from several random events. These are all phenomena where
the majority of individuals are around an average, with decreasing proportions below
and above this average. Here is a very telling example, with the distribution of the
population by IQ:
Pr
oportion of the population by IQ—Alessio Damato, Mikhail Ryazanov
The random module lets you generate random numbers according to this law: i.e.,
you are much more likely to have values close to the average (with the example
above, between 85 and 115) than extreme values (close to 70 or 130). The
corresponding function is called gauss(mean, standard_deviation) .
Here is an example with a distribution centered at 0 and with a standard deviation of
1 (which is a “conventional” normal distribution):
We can see here, with 10 values, that the majority of the values are close to 0.
The evolution of this is the choices function, now making it possible to select a
sample from the initial list, with replacement:
Note how, in the second line, we get “two” returned twice, because the first “two” was
effectively put back into the list once it was initially drawn.
Further Reading
The random module offers more functions than those presented in this course, even
though you have seen the ones that are most commonly used in practice. If you want
to go further, you can consult the official documentation of the random module,
which lists all the possibilities offered by it.
You should also know that the numpy package, which we briefly mentioned in the
previous chapter, also includes the random module. There, you will find all the
functions seen above. All functions are accessible via the line (for example):