Python Fundamentals Numbers
Transcript from the "Numbers" Lesson
>> Nina Zakharenko: In Python, these are all integers.
>> Nina Zakharenko: That's a negative number, we have zero. We also have floating type. So to make a number a floating type, you just add a decimal place.
>> Nina Zakharenko: Let's make that 0.5. Are you all typing along with me? Let's get that muscle memory going.
[00:00:27] Okay, so let's make a few integers, a positive one, a negative one, and zero. You can name them whatever you want. And then some floating point numbers, a positive floating point, a negative floating point, and lastly, zero.
>> Nina Zakharenko: So if we look at the value of z now, we'll see that it's 0.0.
[00:00:56] Python also has complex numbers,
>> Nina Zakharenko: And they are just represented by a j. Unless you're doing mathy stuff, you probably won't need to use them. In Python, integers and simple data types are just objects under the hood. That means that you can just create new ones by calling the methods associated with their types.
[00:01:24] So for example, if I check the type of, let's look at y, we'll see that it's a float. And if I make a new number a and I check its type, we'll see that it's an int. So if I wanted to make new instances of these, I can also say in 5, float 3.0, etc.
[00:01:54] Not necessarily useful now, you won't see this commonly used for simple code, but it'll come in advantage later. And then we saw some mathematical operations. So let's say I have x equals 5 and y equals 3.0, I can add these numbers together, I can divide numbers, let's say 6 divided by 2, I can multiply them, so standard math operations.
>> Nina Zakharenko: And just notice here that when I divided two integers, the end result was a floating point number.