 Hey, what's up everybody? RootedLinol here coming back at you with some more Python programming tutorials still looking at Senpai and now we're moving on to a new topic the carrot symbol to take something to the power and Division now these are weird things right these are this is another Another kind of segment of the online tutorial and documentation that you should totally be checking out rather than looking at my videos But again these videos are kind of a walkthrough and a guide through that So if you want a video presentation here, I am for you. Here we go Let's jump into Senpai from Senpai import all and that works fine for us now notice at least in the last tutorial What we're doing is we were using a X plus one Times times two now I'm using the asterisk twice and it looks like times times to represent Something to the power of two something squared now. I know maybe most people think oh you can just use the carrot sign, right? That kind of represents bringing something up like to the power or something, but that doesn't work in Python in Python this carrot symbol represents, you know Logical exclusive or and if you knew stuff about Boolean variables and logical operands that means like true Carrot false is gonna return true because if you have any true statement in a logical exclusive or it's always gonna return true true Carrot true is equal false. Okay, I guess only if only one thing is equal to true I don't I don't I don't forget no man X X carrot Y Those aren't defined, but if those were symbols X and Y X and Y Now I use X Carrot Y. It's X or X Y and this that's just a Python object to represent this logical exclusive or so here We come into a small tidbit and tangent on how SimPy works When you type something like X plus one when you get your symbol and your integer put together Notice that the SimPy symbol X is Added to the Python integer one. This is still a Python integer type now Python's operator rules tell SimPy that to tell Python anyway SimPy objects know how to be added to Python integers So that means that this one one right here is automatically converted to the symbol Python or SimPy integer object like integer one This this integer function that I just kind of wrote out for you is within SimPy It just means that it's gonna convert what it can to a SimPy object of an integer SimPy dot integer So that's how it kind of works behind the scenes, but this this operator magic Isn't typically visible to you when you really don't even know that it's need to know that it's happening, right? But there is one exception when you combine a SimPy object and another SimPy object like X plus integer one or a SimPy object and a Python object like X plus one You get a SimPy object. It's gonna return either a symbolic object or That's just it. It's gonna return a symbolic object But if you combine two Python objects like two plus one both being Python integers You're gonna get a Python object like a Python integer now SimPy doesn't come into play when that happens. You're gonna get a simple Python object Here we go. Let's take a look at it with the with the type Function in Python. It's gonna return a type right one is a type of an integer If I use SimPy's integer function and know that this is one it's gonna tell me oh, this is a SimPy object Numbers one whatever. Okay, that works just fine for us. Now if I did type Integer a SimPy object plus a Python object a Python integer. It's still gonna return a SimPy integer But what if we did like I told you the latter a Python object with a Python object one plus one It's gonna return a simple Python object Now this normally isn't a big deal. This normally doesn't matter Python integers work pretty much the same way as SimPy integers, but there's one important exception Division now in SimPy the division of two integers typically gives a rational here. I'll show this out here If we had integer within SimPy one divided by integer SimPy three We get one over three and if I throw this into our type function within Python we know Hey, it's a SimPy object and it's rational. That's another it's another object class here rational And we can actually create this represents integers and rational numbers pq of any size We can say like oh one Being the numerator and a comma to represent something else and three representing the denominator One third the same output in the same kind of answer and symbolic expression up top integer one over integer three Now in Python this division symbol can represent either Integer division or floating point division now if I did nine divided by three with Python integers I get three now if I did 9.0 divided by three all of a sudden it's float division. I get a float return rather than an integer Now let's see this way. This is important if I did eight divided by three integers I'd get two and it doesn't make any sense. No Eight divided by three does not equal to we can get three in there three times We can get three and then we can get six and we can get really really close to eight But we end up going to nine so we can only fit these two inside eight three and six This is why we use our float division eight point zero divided by three is going to get me two points You know all this jazz because that's trying to get us the approximate answer Now this is where we separate the line between integer division float point division in Python You can kind of change this if you're working in Python two or Python three Or if you've even imported from the future You know you can run it from the future These are two underscores. I can import division Now I can use simply integer eight divided by integer three and I'll get a float value That's I mean hey whatever But we can of course completely avoid this if we use our senpai objects rational Let's say eight over three. Oh, sorry. Holy crap eight comma three Wow didn't mean to screw that one up. Sorry guys And that's really kind of what I wanted to show you for one thing We've got this rational object And I wanted to show you the difference in the way that Python and Senpai handles integers divided by integers or integers in Senpai over integers in Python or Integers in Senpai over integers in Senpai I think you there is a lot of variation and you've got a whole nother mental abstraction When you step away from Python and you look at Senpai and then when you put those two together And you look at both Senpai and Python. So that's the point of these videos Kind of overcoming these strange pitfalls that you see when you're working with both Senpai and Python And I know it's weird to show you these off the bat like before we actually even do anything with the module But it's good to have them in your back pocket. So, uh, that's that's really it That's kind of what I wanted to show you guys Thanks for watching this tutorial. Hope you liked it if you did like the video Hey, drop a like if you have any comments constructed for this isn't please let me know Maybe write a comment or send me a personal message and if you're willing. Hey subscribe. I would appreciate that Hope to see you guys in the next tutorial