 Hello everyone and welcome back to some Python programming tutorials. We're still looking at SimPy I'm Ruder the Null and now we're going to move into some actual cool mathematics and programming stuff today We're gonna be looking at symbols, which is essentially the core of symbolic Computation and now SimPy programming and cool stuff. We're looking at so this is really the baseline the foundation for all of these Coming tutorials so here we are in our Python interpreter We got idle fired up here and what I'm going to do is I'm going to import everything from our SimPy module Normally I had been doing this by import SimPy But I want to have all of the functions and kind of variables in our scope So without having to have to type SimPy in front of them all over and over and over again So the way to do this is from SimPy import all cool there we go now if we're using symbols Symbols are our variables like you know x and y and mathematics and other cool stuff if we get into z and z or whatever So that's what we need to be looking at let's say we wanted a variable x and we just had this expression x plus 1 That's that's pretty normal in mathematics, right? well in Python Always a variable needs a value if we're trying to use x kind of like a mathematical symbol like a mathematical variable Python's not going to know what we're doing. So we have to declare it as a symbol Python's variables are typically going to hold the place of a SimPy symbol You have to define them this way now the way that we do this with SimPy is with a function called symbols And you pass into it here the names as a string So we'll pass in the string x and we'll set this equal to the x variable in Python And that's the way that we kind of declare that we're going to be using a symbol We run this we just hit the enter button It doesn't return anything for us because we just set it to a variable But now it works pretty nicely if I tried x plus 1 now We get returned x plus 1 because SimPy and Python is understanding this as an expression if I use symbols y without Setting it to any variable. We're going to see the return here. It returns y as a symbol Now I haven't set this as a variable so we're not going to use that at all But we still got x. x is still working for us as a symbol within Python And because of SimPy's symbols function. That's the way that we can use this as a real symbolic mathematical value Note that this symbols function what it's going to do is it's going to take A string of variable names and they're typically separated by commas or spaces We could even pass x and y and z and it'll note that okay all of these variables x y and z are going to equal these Now we've got x we've got y and we've got z that works pretty well for us Now let's do some investigating. What if we had these in a different kind of order? We had let's say A and B. A and B are different or different variables we can use But if they were in the order of B comma A keep in mind symbols can read it with commas or spaces B and A Now A is equal to B as a symbol and B is equal to A as a symbol This is a little bit confusing right? Well the A variable in Python is pointing to the symbol B in SimPy So typically when you're talking about this stuff when you're talking about the code and your mathematics and your work with SimPy and Python What we'll be saying is that Python variables refer to obviously Python variables We're going to say variable if I mean to say variable If I mean to say symbol a SimPy symbol how we're interpreting in the mathematics world then we'll say symbol So I know this is a variable in mathematics as well but it's also confusing because it's a Python variable in computer science So when I'm referring to a variable in mathematics I will say symbol I know that's probably a little hard to kind of follow me but the real point behind this is that a Python variable will be stated as a variable And a SimPy symbol will be stated as a symbol Hopefully that's not too confusing I know it gets messy so let's check it out Messy can equal symbols everything I wanted to show this to you guys because now messy being a variable is a symbol everything I want to show this to you because it can also display that symbols can have names that are longer than one character if you want to have them that way Typically the best practice is to assign symbols to Python variables that have the same name But this can kind of be led to a few exceptions Symbol names cannot contain characters that can contain characters that are not allowed in Python variables like starting with an integer or minus signs I think you can use minus signs I'm not typically certain But hey you can play around with it and do what you'd like to do Now note we can have expressions that keep track of all of these variables x and y and z Sorry x is what we can work with We can say x plus one the same example we've been working with before And we can have this expression variable equal x plus one Now we've got our expression x plus one That's fantastic right Now what if we changed the Python variable of x to equal something else Rather than a symbol that we set in Python What if we, a symbol that we set in Sympi sorry What if we change it What if we change the value of x to two Two plus one is three right Yeah yeah yeah So now if we run expression if we look at our expression what do we see here It's still x plus one but we just set x to equal two what the heck Well keep in mind x equals two is set as the Python variable And of course we haven't even changed the expression variable That's still going to equal x plus one while x is a Python symbol It's not a Python variable anymore Of course if we try and reset expression right up here Now if we look at expression we get three Now this is only happening because of order and because of procedural programming Changing x to two had no effect on the expression Because we've only changed the variable but we haven't changed the expression before afterwards You know this behavior is not unique to Sympi it happens all the time in programming If a variable is changed expressions that were changed with that variable do not automatically change Let's take a look at this The tutorial and the documentation online gives us this Give this good example saying x equals a b c and the expression can equal x plus d f you know And if we were to look at the expression e x p r and if we change x to equal a b c And then if we look at the expression one more time it's still a b c d f Because we only changed x we didn't change the expression And this just has another layer of higher order of brain thinking Because now we're looking at Python Sympi symbols on top of Python variables So that can get a little jumbled in your head but it shouldn't have to Just know that anything that you set as a symbol it's going to work as a symbol And symbols sorry There you go Okay I think that's kind of all that I want to talk about in this video I'm actually simply introducing x symbols to you and they're treated as variables You can do as many things as you kind of want with them It's simply variables that work in mathematics as well in the computer science and programming realm So play around with it if you want We still got y and stuff like that We can use x plus y and they're still going to be working as the variables that they need to work as y minus x 30 times y minus x Just do math if you want Hey dude it's your world it's your playground Playing this playground So there you go guys I hope you enjoyed this tutorial Again it was kind of a foundational thing Knowing how to create symbols in Sympi and how we're going to be able to use them in Python The work that we do Alright thanks for watching everybody Hope you enjoyed this tutorial I'll talk to you later