Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome back.
Let's talk about our first data type and you know what let's do two at the same time.
We have it and floats it stands for integer as you can see here and float stands for a floating point
number.
Let's explore that first.
Let's start off with integer an integer is well a number three or four or five.
These are all integers in a programming language.
You can use integers to do mathematical operations for example two plus four.
If I run this well nothing gets printed.
Because again we have to perform some action on these data types and one action that we've learned so
far is this idea of printing and we print something by calling the print keyword with the brackets so
the brackets is almost like saying hey perform this action on these data types and if we run this we
get six right here.
Awesome so not only are we using print but we're also using the plus sign to perform an action to add
the two data types together.
And as you can imagine we can do most mathematical operations the basic ones we can do negative we can
do let's say two times for and then we can also do two divided by four and in fact click run here.
All right.
It looks like everything is working.
We've added We've subtracted.
We've multiplied.
And then we've also divide it.
Now here's the interesting part.
Up until now we've used what we call integers that is these are a whole numbers.
There's no decimal places.
They're just well integers and a neat trick that I can do here is I can actually say hey what's the
type of two plus four if I click Run here All right let's let's decipher what just happened I've taught
you a another action that we can perform which is something called type which tells us hey what data
type is this and just like in math we go bracket by bracket.
So the first part Python says hey what's two plus four.
Well that's going to be six and it's going to say hey what's the type of six.
Well the type of six that's an integer.
So it's going to say class and we don't have to worry about the class keyword for now.
That's something that we'll talk about later.
But we see here that we're using I.A. for integer.
And then finally after this gets evaluated by Python we print out whatever this does which is class
int now.
Check this out.
Let's do the same for all these ones as well.
So we're gonna say type here type
and then type here.
And if this syntax is intimidating Don't worry.
This is something that you get used to.
This is your first programming language.
It is not going to be easy because well if it was easy then everybody would be doing it.
So hang in there.
Trust me as you practice more.
This is going to start making more and more sense.
Now before I click Run what do you think of the output of each one of these lines are ready.
Give it a guess.
And let's click Run.
All right we got it.
Four six we have negative 2 here which is also an integer.
We have eight here which again is also an integer.
But then we have float because two divided by four is zero point five.
What is that.
Well remember we are talking about two data types here.
We're talking about int and float and float is what we call a floating point number a floating point
number is simply a number with a decimal point.
In our case this is zero point five.
So it's a floating point number so if we write a number let's say we'll do print type and then I'll
say zero point 0 0 0 0 1.
What do you think we'll get.
Well we would get a float if I do five point 0 0 0 1.
Again we'll get a float.
What about the number zero if I click Run I get an int because while there's no decimal points why do
we need to make this distinction in programming and specifically in python.
Well it's because a float takes up actually a lot more space in memory than an integer.
Right.
Because remember this number the number six.
This needs to get stored in memory.
On our machine.
And remember that machines don't really understand this.
They understand zeros and one and they store this number in something called a binary or binary numbers
which is zeros and ones.
Now the problem is when you have a decimal places like zero point or less to ten point five six it's
hard to represent that in a binary number of zeros and ones because of this point.
So a floating point number essentially stores these numbers in two different location one for the 10
and one for 56.
Now we don't need to get technical here but that's the idea.
The idea is that we need more memory to store a number like this than a number like this.
Now the topic of floating point numbers is really really interesting and I'll link to a resource but
the best way to learn more about floating points.
Again it's not super important that you know the technical details but if you go to a floating point
number Python
again you want to make sure that you go to the documentation for version 3 and you can actually learn
about floating point Earth mistake and these official documentation by Python are always a good tool
for you to use whenever you get confused about something or you want to get a little bit more extra
detail but let's get back to the topic at hand both int and float are used for while numbers right and
python is going to automatically format the type to whatever will make sense.
For example if in here I do 20 plus one point one one is a integer the other one is a floating point
number but when I click Run here automatically python is going to convert it to float.
Let's remove these here so that we don't get confused by them so if I run this we see that this whole
expression is converted into well a float.
Now if I do let's say nine point nine here which will equal to eleven and I click Run these two floats
add up to while still a floating point number because if I remove that type from here and I click Run
It gives me the result eleven point zero.
It keeps the floating point numbers all right but at the end of the day what we care about is that that
Python works the way we expect it to.
That is we can do mathematical operations as a matter of fact we can do a few other things as well.
There's also this idea of the double multiply so this means to the power of so two to the power of two.
Well that's going to equal 4 to do the power of 3 is going to equal 8.
We also have the double divide that is that we can do to divide it by 4 but then we use two slashes
here.
If I click Run here I get zero this actually returns an integer rounded down.
If I do three divided by four I get zero but if I do five divided by 4 I get one this gets rounded down
to a integer.
Finally the last operator that we're going to learn about is called modulo and it looks something like
this.
If I do 5 modulo which is the percent sign divided by 4 or modulo 4 5 run this I get 1 modulo is used
to represent what's the remainder of this division.
So if I divide 5 by for the remainder of this division will be 1.
If I do 6 divided by 4 with modulo and I run I get to 2 is the remainder of 4 All right.
Let's take a break and learn a little bit more about these numbers in the next video by.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.