By now, we have only used round numbers in
variables, which we can also call integers. But in
fact, there are more types you can use to
represent different kinds of data. And let's
discover them now. And first, I'm going to give
you another useful Python function, which is named
type. Okay. So in Python, you have some built in
functions you can use, okay, and to call a
function, it's simple. You just write the name of
the function, and then open and close parentheses
and in the parentheses, you're going to give any
parameter you need to give. Sometimes there is no
parameter, sometimes you have to give parameters.
So here, let's say I give type 3. So I simply
put a round number here, inside the type function,
and this gives us class int. So don't worry about
the class for now. Okay, just focus here on the int. So
int for integer, so I have my variable a, which is
equal to five. If I do type a, okay, I can also
get type of a variable directly, and you can see
type integer. So this is the first type, okay, you
have used and one of the most important. Now let's
say, type(4.5). This is, as you can see, now it's
not int anymore, it is float. So this is a float
number. If I do type(3.0), we also get float. Okay,
you can see as soon as I add a point to the
number, even if after this is zero, we get the
float number. So this is a different datatype
okay, int and float. And so if I do, let's say e
is equal to 4.6, and then I do type(e), I get class
float. So at anytime, you can just use type with
the name of the variable to see what kind of data
type you have here. Okay, now let's see, let's say
do type(4+6). Okay, you can see so 4
+ 6 will be evaluated to 10. And then 10 will
be passed to the type function, and this is going
to give us int. Now if I do type, let's say (4.5+4.3),
okay, you can see the result is float.
And if I do type(4.5+3), so here I am
adding a float number and an int number, and the
result will be float. So you can see whenever you
use a float number in an operation, when the
result is going to be float. So great. We have two
main datatype for numbers, integers and float
numbers. Now we're going to see two new other data
types, which are representing other things than
numbered. The first one is a Boolean. So if I
write True, okay, if I write False like this, so
True with uppercase and False also with
uppercase, you can see it's working, this is
working nicely, because those are values you can
use, okay? Those are Boolean values. So a Boolean
is simply a data type, which only has two values,
True or False. And we are going to come back to
this actually, later when we work on conditions.
So that will be very useful to create conditions.
So if I do type
(True), you can see class bool for Boolean, can also
type(False) Boolean. Okay, and then the fourth type
we're going to see here is the string datatype. So
if I do type("hello"), like this, you can see class,
str, str for string. And one thing about strings
is that you can use if you want double quotes or
single quotes, okay, you can see this is also
going to give us string. So for now, the
difference is not that important. I'm just going
to follow and continue to close with double quotes
like this. But the important thing is that you
stay consistent. So if you use double quotes, you
use double quotes at the end. If you use single
quotes, you use a single quote at the end, okay,
if I try to do let's say "hello', like this, I open
with a double quote, I close with a single quote,
I'm going to have a SyntaxError, okay? This is
not going to work. So if I just create a text
variable, which contains "Hello", for example, and
then I do type(text), I get class str, and one thing
that is important is whenever you add quotes to
actually anything, this is going to become a
string. Okay. If I add quote to three, this is
a string Okay. This is not an int number. Okay,
very important to make difference, okay, you can
have three, but this can be a string because you
have put quotes. Same for, let's say 3.0, which
3.0 is a float number, but this is a string, and
also type, if I do True like this, this is also a
string. Okay, and one thing you can do also with
strings, these, you can use the plus operator.
So if I do hello, like this plus, let's say,
world. So I have added the space here. Okay, I
press Enter, and you can see the result is hello
world. So this is a specificity of strings.
Because of course, for a string, it doesn't make
any sense to kind of multiply two strings, okay.
But you can use the plus sign to just concatenate
two different strings and make it just one string,
and the result will be a string. Okay, so if you
try to do type on this, you will get also str. And
this, of course, you can store it inside a
variable. You could create one variable for this
one variable for this and create a new variable,
where you just add the two variables, and you will
get the same result. So great, you have just
discovered four Python data types, you're going to
use in all your future programs, integer, float,
Boolean, and string. One thing to note here, you
don't need to manually precise the datatype. When
you create a variable, the data type will be
automatically evaluated, depending on the value
you're assigned to the variable. And one other super
important thing, try not to change a variable
datatype after you have created it. So for
example, let's say I have name, which is equal to
Ed. Okay, name contains Ed and I can type name,
okay, this is an str. Now, what I can also do, and
this is valid in Python, I can just do name is
equal to two. So no name is to any file type name,
I got class ints. So the name was before when I
created name for the first time it was a string
and now it is an integer. This is a very bad practice,
don't do that. Okay, you won't get a Python error
when you just assign a new value with a new type
to the variable. But this is a sure way to mess
up with your program and get a lot of errors later
on. So once you've created the variable stick to
the same data type for this variable. And because I
have also previously told you to use meaningful
names, so let's use a few examples. For example,
you have the user_age, okay, 45 or 55. You have
you can use the user_name for example, let's say,
Bob, okay. And then if you want to float number,
let's say room_temperature, which is equal to
34.5. And let's say is_activated which is equal to
False. Okay, so here you have an example with four
different variables with four different data types
and with meaningful names.