The name of this video is Conditionals Lesson. So now we're on to conditionals and conditionals are, I think like iteration, another really interesting part of the code that allows us to do quite a lot with it. They're part of the control flow family. So, sometimes encoding we need to ask a question, to see, to check the condition of something, and then to change the behavior to change the flow of the code if that condition isn't met or if it is met. And conditionals working with operators really gives us the chance to do that. The simplest form of a conditional is the if then statement and the conditional statement actually shares a lot with the structure of the iteration statement. So it has a colon and it has an indent just like the iteration statement. In this part of the conditional statement, This x is greater than 0 is what's called the condition. And a conditional statement returns either a true or false depending on that condition. So in this case, if x is greater than 0, it's going to return a true and if it returns a true then it runs what's in the indent of the condition and so it would print out, x is positive. Now there's another there's a very useful way of looking at conditional statements to both work on and demonstrate their logic and that's to use a flow diagram. So this is showing the flow of the code from top to bottom. And so we enter into the conditional statement here. We asked this question. If the condition is true, then it runs what's within the conditional statement, which is print 'x is positive. If it's false, then it just bypasses that and it runs whatever else is beyond that. Now in this example, there's nothing beyond that. So if I was to run this code, and if x was less than 0, it wouldn't print anything at all, but it wouldn't break. It wouldn't throw an error, it would work just fine I can have as many if then statements as I want in a row. I can have as many if then conditional statements as I want within one code. That doesn't matter. And so this by just adding those if statements, this thing gives us some other options. So if x is in fact greater than, or excuse me less than zero, it would this of course, would be bypassed. So I would get a false but then it's going to go to this next line of code and it would print out that it's negative. If x and remember this operator is asking the question, if x is equal to it's not setting x equal to, it's asking the question is x equal to zero? If that returns a true statement, then it would print out x is zero because that's within the conditional. The next form of conditional is the If-Then-Else Logic, which is often referred to as alternative execution. And so it gives me two branches, or two options within my conditional. And the way this works is that, if and I'm looking for a remainder here, remember what that percentage is asking for. So if x is, let's say 10, for example, then my remainder would be equal to 0. And so x would be even. And that's going to run if this returns a true statement. If I get a false then it's going to jump and it's going to run, it's not even going to ask a question. It's just going to run else whatever is in indented within else is going to run. So else will run at the end of the conditional if I get faults all false statements. And that's represented by this diagram. I have two branches, the true on the right, the false on the left. And then, after they're done with either, They both continue with the flow. If there's anything that follows them in the code. If-Then-Elif-Else, if I need more than two branches or two options I can use the If-Then-Elif-Else Logic sometimes called Chained Execution. And that's using this statement, which is an abbreviation of elif, these are run in order and so again these are asking a true false, this is asking a true false. So if this returns a false, it's then going to go jump to the elif statement. Elif statement, ask a question. It's not like the else statement. So it's asking a question. If it is true, then it will run what's in the indent. If both of these return a faults, then it would automatically run What's in the else. And that's showing that flow, so if I get a false for both of them, it bypasses those and and this is what the else runs., Or if I get a true in the if it's going to run that, it's going to bypass the elif and it's also going to bypass the else. I can have as many elif statements as I want within chain execution, so it allows for a lot of options. And I don't have to have an else statement, that's optional, I don't need to put that in to end this conditional. Our last form of conditionals and probably the most rarely used form of conditional, because I can usually do what I want to do with chained execution but nested is a possibility. So if I take Else-If-Else example that I showed and rewrite it as a Nested Conditional, it would look something like this. And so I have two outer branches, I have an if and an else. So this is either going to be true. If that's true and it's just going to bypass all of that. If it returns a false, then it's going to go and run whatever's in our else statement which is this series of, it's a new conditional statement. And so it's going to run those again and it'll return a true of false. It's false, then it would run that else statement. And that's the flow of our nested conditionals. Again, they can be a little strange. I mean, one thing to keep in mind with a nested conditional is the hierarchy of the indent. All right, so I've been indent here and then I have another indent here. Wouldn't have it there, but I haven't indent here. Keeping those, the level of indents straight can often be confusing. And so again, they're not often used. So conditionals are really a kind of logic brain of our program, and are going to allow us to do quite a bit with our inputs and any data that we generate within our code. And they're going to give us a lot of options for different things that we can do with our geometry, given different conditions. And so they're really, actually quite an exciting part of the code because they allow us to develop specific logics. And so we're going to show a bunch of examples and we're going to use them throughout the remainder of the course.