 So what if I want to design my own functions, you know, I've been using other people's functions I've been using the math library the random library What if I want to build my own kind of Functionality and what I can do is I can actually do that obviously and To do that what I do is I come in and I utilize something called the def command now the def Basically is saying define this function and I give it whatever that functions name is going to be So in this case plus one, that's the name of my function and then I give it whatever Parameters I'm expecting this to take now in this case Plus one is expecting one parameter over here and say hello. It's also expecting one parameter in this case name So now what we can do with this is we can do two different things one over here on say hello I Can just do a print statement now you notice over here, there's no You know What happens after prints, you know what happens when I'm done Well in this case nothing happens. I just call say hello and I'm done with it But what if I want to save sort of the value I'm calculating out? Obviously, that's what we're doing when we do say the math class We're the math library when I call math that sqrt. I get a number back I want to be able to use that number the same kind of concept comes in here and to do that I Use something called return now what return will do is it'll come in and it will spit out that same number for me So let's kind of see that in action. I Say for example, I want to design my own sort of method function, I'll call it deaf my Function and I'm gonna give it One variable. I'm gonna call it. I'm gonna call it x. I'm gonna call it variable. Why not? Once I've done this I give it a colon This is basically my wave just like with an if statement I come in and I'm saying that all the code inside of these this tabbed area is gonna all of a sudden be a part of the My function function. So what am I gonna do with that? Well, I'm gonna say that variable is gonna equal variable Raise to the second power. Okay, and then variable is gonna equal variable Times negative one and then I'm gonna go variable Equals math Dot, I don't know sqrt variable Now I do have to kind of come in because I'm using the math library all of a sudden I have to import Math So all of a sudden I've created these different things now. I'm not 100% done just yet and the square root of a negative number Just to make it easy on myself. I mean, I just put it as a three. I know Variables just sitting floating in space with my function if I were to come in afterwards and try and print this my Function with I don't know 10 Well, mathematically, I can kind of see what I would be doing here I'd be saying 10 raised to the second power a hundred Hundred times three three hundred. What's the square root of three hundred? Off the top of head Not even gonna try I guess But all of a sudden, you know, that's not what we're going to see when I save this. Let me save this just call it function demo Dot pie and so when I run this I Get none I get none the reason why is because Variable variable never leaves my function So that's where this return comes into play by me saying return Before my function kind of finishes packs up goes out of memory and all that nonsense Go ahead and save it for a second Kind of move it, you know, put it out In our case to this print statement. So now all of a sudden when I run this instead of seeing none I should see 17.32. So now all of a sudden I can have some of that ability Again, I'm able to still have methods functions define my function to Name that don't have any form of a Return statement I can do something like a print statement print Hello name There's nothing wrong with that, but I just don't have any I can't come in and say for example you know phrase equal My function to Adam and then print Phrase I don't get this ability right here. What I should see is hello, Adam instead what I'm gonna see is my 17 32 because that's what I got with my function And then we see hello Adam because that's being called inside of my My function to but then when I go to actually print phrase Again a none now is at the end of the world. No, you just would not do this Whereas this is perfectly valid right here Now we're getting somewhere One other thing that we can also do is we can also add in more variables so I can come in and say def my function three Instead of just having one variable. I can come in and separate these by commas and go variable to Variable three as many as I want I'll go for and All I'm going to have this do is return all of them added together. So return Var one plus var two plus var three get my spacing right Three plus var four boom Same kind of song and dance can come in echo And I can put in here one two Four that's what I wrote five. I run this I should see 17 point 32 again because this is still getting printed I should see hello Adam because my function two is printing inside of it And then I should see one plus two plus four plus five which is 12 because of my function three and Takes one positional argument before we're given what ah Always check code. I put my function my function is only expecting one variable. So It's yelling at me. It's saying. Oh, you gave me four when you should have only gave me one That's because I should have been working on function three There we go. Now when I run it, I should see 17. Hello Adam 12