2.8 Numbers (Deep-Dive) - IP

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with

Already have an account? Sign In »

2 hours 57 minutes
Video Transcription
Hello, everyone. And welcome back to enter the python here on Cyber Eri on demand, I am your instructor, Joe Perry. And in this video, in this lesson, Lesson seven, we're gonna be talking all about python numbers. So numbers in Python, we've used a bunch of them. So far, we've done a bunch of logic with them, but I just want to take a few minutes here in this lesson and just kind of break
down all the different components of them
so that we can understand them a little bit more effectively. Before I jump to the VM, I'm jumping the gun a little bit. Our objectives in this video we're gonna learn about the different math operations and python gonna learn by the differences between its and floats and how to use each of those on. And that's really all we're gonna need to worry about for numbers in python.
So much of the hard work of numbers is abstracted away from us, so we don't have to worry about,
um they do have methods much like strings do. But for the sake of an introductory course, we're not really gonna be worried about those.
So their math operations and python or just like math operations in, well, math.
We could do things like four plus
five minus four.
One will do 10
times eight
and as a little example right here, 20 divided by
five. Now you'll notice this is different, and I have kind of alluded to it. In previous videos
that printed 4.0,
there is a difference in the difference that I mentioned right here in this objective between EMTs and floats and in python. All of these things are numbers, and python will use it and make it work just fine. But
it is worth noting that there is something under the hood being abstracted away from you that can be useful and can be important.
So when you're doing division, if you don't want to get back in decimal place, you'll do what's called floor division,
which is going to just divide and just give you sort of the round number of that division. So remember, from our use of Modelo in a previous video that we did 20 module 05 who will give us the remainder, which, in this case, of course, 0 21 module 05 would be one.
So if we did 21 module 05 and 21 floor divided by five.
We'll see that four, even though 21 isn't evenly divisible by 54 is the dividend, and one is the remainder. And I think I'm using that word right. I think its dividend it might be divisor. I haven't actually had to use the names for arithmetic in, like 20 years or so,
but so that's the basic way of using instant floats. That's the difference between them. The primary thing to understand about floats is that floats have decimal places. Floats can address non whole integers integers our whole numbers. They could be negative or positive. They're just never going to be sort of, you know, fractional number.
Where's floats can address fractional numbers.
So I showed you. We have plus minus times. Divide. We also have exponentially ation available to us
four to the power of four is gonna be 256.
Then we have one more subject in numbers. Numbers is a much easier lesson than strings.
One more subject of numbers. It's really, really cool to address.
There's a special number in Python.
It's not really a number. So just a placeholder for a number.
And that's the underscored.
And you can see here that now underscore equals 256 because it is the result of the last operation, the last mathematical operations.
So if we did five plus three
and pretty underscore,
it'll be eight and underscores just a useful way to track math we can do. I'll show you in just a 2nd 1 of the other really cool things we could do with it. But I do want to point out never, ever do that. Never assign a value explicitly to underscore is what will actually happen there is. You'll create a new variable
and you're gonna blow away. The built in sort of magical underscored would never, ever do that.
But one of the other things you could do with underscore with the sort of pseudo number that is underscored is you can use it in loops for underscore in range
and what's cool about this is what it's really doing is it's just saying for each number in this range, without ever actually storing that number anywhere, it's just sort of a useful shorthand in Python, where you're just trying to use that range for just a count. The number of times you're doing something and the number itself isn't relevant
is actually all there really is to math operations in Python. You do them the same way you would do in algebra if you have to use an order of operations that works exactly the same way it does in math.
And then we talked about the differences between imagers and floats. The idea that floats can use fractional numbers.
That's all there is to lessen. Seven. It's sort of a palate cleanser between strings and the much more interesting or, well, much more interesting and somewhat more challenging lists and dictionaries there coming up. Speaking of which, I hope to see you back in our next lesson. Lesson eight. We're going to do a deep dive on lists and, of course, all of the material for lessons five through nine.
We have a lab four provided by the spectacular company. Next check.
I know that I keep talking about them. I actually should probably address that they are a partner of Cyber Eri, but they're not actually sponsoring this video in any way
They're not. You know, I'm not being paid to talk about them or anything like that. We just use their lab. And absolutely, I just love it so very much. And I want all of you to use it as well.
Eso please, by all means. Take sometime, do those exercises and really just dig into the code. I'll see you back for less than eight. Thank you. As always for watching I'm your instructor, Joe Perry. And you've been watching intruder python here on Cyber eri on demand.
Up Next
Intro to Python

This is an introductory course on Python for cyber security, giving students the ability to understand the basics of the language, solve problems with scripts and identify useful Python modules.

Instructed By