So I have explained to you already in the previous lecture that Python handles data types in a very
convenient manner.
For example, if we divide two integer numbers, it will give us a floating point number, which is
very convenient because then we don't have to be careful what we're doing.
So we can just write whatever we want to do, and it gives us the correct results.
So let's discuss a bit more the different data types and especially who will start with the numbers.
So we will discuss integer float and complex data types.
So for example, when we write five, then of course it will be a five and integer number.
But if we write 5.0, even though it's mathematically speaking exactly the same thing, the output will
be 5.0.
And you can see that both of these have different data types.
So the five is an integer number and the 5.0 is a floating point number.
So as I mentioned, there is really no need to define the data type.
Python is really handy and using or in dealing with these data types in a very convenient manner, and
it does everything automatically.
So we can, for example, just add these two numbers five integer and floating point five, and the
result will be a floating point ten.
So if for whatever reason, you want to convert different data types from one to another.
This is, of course, possible.
For example, this could be useful for creating some output where the result would be just 10.
And instead, the output would normally be expressed as ten point zero.
So then in this case, you could, for example, turn this into an integer number so we can turn integer
numbers into floating points numbers and we can do it the other way around.
And here you must be a bit careful because if you try to transform a floating point number that is not
dot zero into an integer number, then of course you will lose some information.
You will make a small error.
So this will not really round the number, but we'll just cut off the floating point number, so all
of the digits after the comma or the dots.
So in this case, int of 5.9 is just five.
If you want to really do mathematical around operation, then you're right around five point nine and
then it will give you six.
So now we know about integer data type and float data type and something that's also very important,
especially for physics programming is complex numbers.
So the complex data type, so I hope you know this, that a complex number consists out of a real part
and an imaginary part, and the imaginary part is just a floating point number, a real number multiplied
by the imaginary unit.
So in mathematics, this unit is called Are you?
But in Python, it's called Jane.
So if you're just right, Jane, there's a bit of a problem because J is not defined, it just means
could mean a variable that we could define, for example, J for one.
So if you want to have the imaginary unit I or in Python J and you must write something like one J.
Or you must write something like two g.
So special property.
Sorry, I didn't take so long.
So the special property of this imaginary unit is that the square of this number is negative.
It's minus one.
So if you run this, you will see the result is minus one plus zero g, so basically just minus one.
So this allows us to calculate the square root of a negative number.
So, for example, we could write and, um, pi square root of minus one.
Um, and it tells us there is an invalid number, but what we could do is something like this
because then we tell our computer or our Python program that we want to consider complex numbers.
So in this case, there's minus one has the data type of a complex so we can calculate the square root,
which will then be J.
Or in mathematical language, the imaginary unit I sent.
The type of such a complex number is, of course, complex, and we can, of course, to all the basic
mathematical operations, for example, multiplication.
So if we multiply these two complex numbers here.
We get another complex number, and the result will be the real part is three times one, which is three.
And then the other contribution to the real part would be five eye times too high, which would be 10.
I squirt.
So I squared, it's minus one.
So this is minus 10.
So we have three minus 10 as minus seven.
And then for the imaginary part, we have two terms.
So we have five times one, which is five.
And we have three times too high, which is six I.
So we have five plus six I, which is 11 I.
So you see, we can really do all of the operations using complex numbers, but also you see that sometimes
we must be careful because here we had the problem when we wrote and p square root of minus one gave
us a mistake.
But if we write this as a complex number, then it works.
So let's see if this works.
Oh, sorry, forgot the brackets.
So now it works.
So if we turn the real number or the integer number into a complex number, then you can use the square
root command.
So sometimes when using complex numbers, you must be a bit careful with the data types.
But most of the times Python will manage all of these things just fine, and you don't need to watch
out for some problems like you have to do in other programming languages.