- [Instructor] In our previous video,
we took a look at the interactive interpreter
and specifically we saw the idol environment,
that's where we are now.
And in this video we want to take a look at some different
data types that we can use within Python.
For example, if we do a bit of math,
if we say, three times four,
like we did in the previous video, we see that that is a 12,
well, that number is an integer, that's a data type.
And we can see the data type of something by
using the type function.
I could say type,
and then in parentheses put the number four,
and that's going to come back and say the class is, INT,
that's short for integer.
What if I said, 4.5, if I used a decimal.
If I say type, open parentheses,
four dot five, close parentheses,
here, the data type is float,
that means a floating point value.
That's a number that has a decimal in it.
If I have a string, I could say type,
open parentheses, open quote and I'll give my name of Kevin,
close quote, close parentheses, that type is a string.
And we said that when we print strings,
for example, if I said print, open parentheses,
Kevin Wallace,
when we print a string like my name,
we have to put the string in quotes.
And here's something that's interesting,
I can even assign values to a variable.
Earlier, we were doing three times four,
what if I said X equals three,
so I've assigned the value of three to the variable of X.
Now I can do the mathematical operation of
X times four, which is really three times four
because we assign three to X and the result is 12.
We could even do some mathematical operations with strings.
Check this out.
What if I said, Kevin, in quotes, times four,
what would happen there?
t gives me four instances of the name, Kevin.
We can assign strings to variables also,
let's say, I have a variable of first name
and remember we mentioned in a prior video that
I'm using something called camel case
or some people call it mixed case
where I have a variable with more than one word in it,
sort of, shoved together, first name are grouped together,
and I don't capitalize the first word,
but I capitalize all subsequent words,
we might use that for variable names or file names.
First name, the N in name is capitalized,
the F in first is not.
But I'll say first name equals, and then in quotes, Kevin.
And I want to print out my first name,
space and my last name using variables,
so I need another variable just for the space.
I'll say, space, equals, quote, space, quote.
And then let's do last name.
I'll say last name, equals in quotes, Wallace, close quotes.
Now let's do an operation,
it's not really a mathematical operation,
I'm adding strings together.
The term for it is a concatenation.
A concatenation is when we put multiple string values
end to end.
I'm going to say, print,
open parentheses, and I'm using variables
so I don't use quotes here.
I'm going to say, print,
the variable of first name plus the variable of space
plus the variable of last name, close parentheses,
we'll press enter, and it printed the value end to end,
it did a concatenation of those three variables.
The first name, of Kevin, the space,
and the last name, of Wallace.
Now let's consider a Boolean data type.
And you're probably familiar with Boolean logic such as
something less than or greater than or equal to something.
In fact, the result is going to be either a true or a false.
If I say type and then in parentheses I put true,
it says, oh yeah, that's a Boolean data type.
And we could do a test like this,
I could say, this first name equal Kevin,
I could say first name,
now, I can not just say, does it equal,
by saying a single equal sign,
that's how we assign a value to a variable.
In order to do a Boolean test,
I need to do two characters here.
I do a double equal sign.
This first name, equal equal, Kevin.
And Kevin is a string, so I'll put that in quotes,
close quote, press enter, and it says, true,
that is a true statement.
If I did, first name,
two equal signs, and Wallace, that's not true,
so it's going to come back and say, false.
Or I could say, not equal to by saying, first name,
exclamation point, equal sign, that means not equal to,
Wallace,
and that will be true because the first name is Kevin,
that's not equal to Wallace.
We could do these Boolean operations with numbers.
For example, if I say, is three less than three,
no it's not.
But if I say, is three less than or equal to three,
that's true, yes it is.
We could even see if a string is inside of a variable.
I could say, in quotes, W, and I can say, N,
that's going to do a Boolean check,
is WN the variable of last name
or the value assigned to the variable of the last name?
And it is because the last name variable
has a value of Wallace assigned
which does contain a W.
And that's a look at a few different data types
that we have within Python.
We took a look at an integer, which is a whole number.
We took a look at a floating point data type,
which has a decimal value.
We took a look at a string, which we put in quotes,
and we took a look at the Boolean data types,
of true or false.