 Hey, what's going on guys? This is root from no shell.com and today we're gonna be looking at some more python Just last tutorial we looked at some data types And now we want to learn how to operate on these data types and be able to manipulate them So let's get idle started up and let's get to programming and all that good stuff So when you operate or you you change a value of a certain data type What you're doing is you're using an operator on it now these operators can be the symbol if you look at this table here You have the addition you have subtraction you have multiplication And these are usually only things you would be doing with numbers But you can sort of manipulate this tactic with strings too So if we hop on over to our python shell we can try it out I took out an example here like a little action on the right hand side of the table So two plus four if we just type that in we get six Idle almost kind of works as a calculator or something But that just makes sense if if you're running a computer things should be able to be calculated and computed and in a programming language That's exactly what happens everything everything every expression that you type in will be evaluated the way it should be So let's hop on over to subtraction those six minus four is gonna get you to that same thing that we had right up here So obviously we're we're right So three times three when you're looking at multiplication you're gonna have nine right there you go Now we have division which is a little bit more of an interesting thing if you have ten minus two I'm sorry ten sub ten divided by two you get five now. What if you did ten divided by three? You get three But we all know ten divided by three isn't exactly three if you do if you do that you have three and you have six And you have nine, but you don't have ten ten is just like this little extraneous number right off on the side That doesn't make any sense. So what you're seeing here is a case of integer division So the way this works is you're passing in two integers if you typed in a Ten divided by three exactly that same thing you have those two integers You're getting ten divided by three so you're gonna get the integer as a quotient Now this might not be what you're looking for you might want to have that real thing So what you should do is try and convert these integers to floats Our decimal point numbers and then what you do that is just give them a decimal point Ten point oh divided by three point one three point zero three point three three three three three three whatever you whatever you would expect to see in that answer and That's really the only case that you might have to make up for it Because you are gonna have to deal with integer division and fixing that in case you ever need anything like that But that does bring another interesting case because division is so Quirky, I feel like there's the best word for it. You have the modulus operator Which will return the remainder of a division So if you had that same scenario ten divided by three you're gonna have three And you're gonna have that six you can multiply it again You get nine three times three is nine It's that you have ten and then because that's what you're gonna have there and you that Differt between the ten and the nine is one if you kept going you would get to eleven if you were multiplying I'm sorry you would get to twelve if you were multiplying three by four so now but we're gonna pass in that ten as What we're working with so if we had ten Divided by 3.0. We have that exact same thing. We're using the float, but let's say we don't want that Let's say we want to get the remainder of that of that evaluation. So let's see ten modulus three You're gonna get one because you have that ten But the only the closest thing three can get to it is nine You get that one so there's your remainder and that's really all you need to know It's kind of interesting because you can use that a lot if you're trying to factor numbers If you're trying to write yourself a little like factoring program to see how many like what numbers are factors of this Let's say one is a factor of 20 Let's say two is a factor of 20 because you have times 10 then you have let's say four and then you have five So one times 20 is 20 two times 10 is 24 times five is 20 and you would get that What you could have the user do is input a number Let's say input they input 20 and you could start counting up until 20 And then every time you get a new number you could divide it's you could divide 20 by that new number and if you're If the remainder is zero you can tell that's a factor if you if the remainder isn't zero It's obviously not gonna divide correct It's not gonna like work out correctly because it's not a factor So there you go you get a list of all the things you need to know and boom But that was a little tangent I'm sorry for rambling like that if you look back at the table here We have floor division floor division is interesting what it does is it'll divide and then it will round the answer to the floor So in our scenario ten point three. I'm sorry ten point zero divided by three We don't need these decimal points anymore It's working with integers You get three. I actually haven't tested that out, but that would make sense because you have These things here So yeah, we should I should use those decimal points to be able to Prove to you guys what I'm saying here because you get three point zero rather than three point three three three three three three so As it's rounding down. That's all I'm saying. I'm using my hands here, but you can't see me so So yeah, that's really all you need to know about with numbers and integers and floats you can obviously Do different things. Let's say ten point twenty five times maybe two point five You can multiply with floats you can add with floats you can subtract with floats You can do all these things with different data types that you've learned about in the last video now strings are a whole different story it's kind of really interesting and I'm gonna get more in depth with this later on but I'll introduce to you some like some of the some of the basic concepts So if you have a string, let's say this is a string and Let's just work with that what you can do an idle You can hit alt P and it'll get back your previous command. That's what that P stands for So that'll make things a little bit easier for you and then let's add to it Actually, let's multiply. Let's try and like Repeat the string. Let's this is a string times three. This is a string. This is a string. This is a string there you go and That could be useful. I suppose but it's more It's gonna be more important to be able to add things to the string now This is interesting because if you're trying to like display output of something that the user already inputted So if you wanted to say if you had the user type in something Like if you if you had wrote out to the screen Please type in something and the user typed in something and you wanted to display it back to him You would be like you typed in and then something That's that might be a little bit of a vague explanation But I feel like you're going to want to cat concatenate and that's the term for that's the terminology You would concatenate onto a string concatenate is adding Onto a string So you have the string here and let's concatenate onto it or add This piece was concatenated and now you have One string, but it's both of them put together So now this is an interesting case if you're trying to add it. Let's say a number to it This is going to throw an error at you, but don't be afraid because We have we have a solution. We have the technology. So You can't concatenate a string object and an integer object. So the way we would go about this is Let me bring that back down here You can use string a function that will convert whatever you pass to it to a string So concatenate Concatenating wow, I had that I had that whole thing wrong the entire time. That's embarrassing Concatenating is adding onto a string and you're adding the string value of 30. So it'll just be if we Close that out for a moment. You'll have 30 that's exactly what you're going to be returned with but since you're Let's paste that in concatenating is adding on to a string plus string 30 Concatenating is on to a string 30 good. That's exactly what we wanted to see no errors and it works Now you can subtract with strings. I suppose I Actually, I don't think I've tried this if you typed in This is a string and we were starting to subtract is would it get rid of all the is no that wouldn't make sense Okay, but yeah, this kind this is kind of exactly what I want to show you guys though being able to Experiment and try things and see what works and what doesn't is part of gaining a better Understanding in my opinion if you're able to just toy around for a little bit see what you can do see what things that you Can change see what things you can manipulate and make difference. That's part of building something new and When you're operating on on data in Python You're going to be able to change things in lots of ways whether it be using a function to change things whether you're Going to be adding something at the core minimum So, yeah, that's really all I have to offer for you guys today Be sure you toy around with this a little bit see what you can do Experiment with different data types experiment with different operators do a little research if you feel like you're brave I don't know But thank you guys for watching. I hope this helped and I will see you in the next tutorial