Akash Verma

2019 Best Digital media agencies in Mumbai

So I'm just going to copy this and paste it just put the indentation properly. So now my checklist is yellow and the distance from the light is greater than Digital media agencies in Mumbai Well, in this case, I want to slow down obviously because it is unsafe. So if I now zoom out and go to test this again I get to go. It's green. So let's change my Chatterley state to yellow run again. digital marketing company Slow down as prints out here because obviously I'm too soft from the lights but if I was meters let's say I get speed up being printed out. OK.

So even though the traffic by the state was still yellow because my additional case is different in each of those two examples then I got a different statement being printed out. So the first Test in this case actually passes because this is true and this is true. Digital media agencies in Mumbai Whereas in this case when this is this is true but because this fails this whole test fails a case of both has to be true for the on to pass.

Again this is different from the safer places within or because in this case only one of these two has to be true. If both of them are true that still fine. It's only of both of these are false that the overall test fails. OK. So show you actually, in my opinion, a slightly better way of doing things and that's going to be using nested if statements so I'm just going to copy this and actually comments out. Digital media agencies in Mumbai And I'm going to change paste it down the bottom and make some minor modifications.

So rather than having this and then the and here and adding this extra case, I'm actually going to get rid of this. I'm going to get rid of this unavenged create a nested IF statement. So this if statement now is actually going to be separate from the case statements. And I'm going to consider this if else if an else to be all part of the same statement.

So now, in this case, I'm going to perform an additional test inside of this case so I'm testing for the distance from the light and I'm seeing if it's less than or equal to in this case I'm simply going to print speed up again and I'll do an else. It's all we can do it. Else because in that case I know it's safe. Digital media agencies in Mumbai I'm going to print so down OK. So now this is going to accomplish the same task as above but it's going to be slightly different syntax. So in this case here we had five parts to this statement.

Well, now we only have four parts. But one of the parts contains additional cases within it. So I think this method is actually less more efficient on this because we have to perform a possible four tests to reach the statement. Whereas here we only have to perform a possible three tests before we reach the ALS case. And that seems to be the case in all of this nested IF statement is actually more efficient than the ankle's in a lot of cases if there are lots of different possible values that this can hold. Digital media agencies in Mumbai

Then you probably want to consider the nested IF statement in this case. There's only actually a couple of possible values so it doesn't matter too much. But again we're going to accomplish the same task. So again if this passes we'll ignore everything else. If this fails we'll go on this test now of my trusty glacé is yellow than I need to perform additional tests.

So now I'm testing distance from the lights and that's the case here. And again if this fails then I ignore all of this and move on to my next test. So like I said exact same result it's pretty out slowed down is being printed just like in my distance from the light was we should get the speed up and we do OK. Digital media agencies in Mumbai So that's the basics. If else add L statements.

I do highly encourage you if you kind of confused about what's going on to take a moment here to pause this video and try some stuff of your own so try some different examples and create some variables compare the values and write some if else if and L statements to Tessie's particular use of nested if statements. Use you and do operators because it's important that you understand these moving forwards.

I can't unfortunately right now tell you which times are going to be better for you and which times are going to be best to use you nested IF statement. That really comes down to the individual case and what you're trying to accomplish with the if statement overrule. But with that being said I'm going to assume that you guys are previously comfortable with everything so far.

And so we can move forward to talk about loops. So first of all what are loops because they're actually a little bit different from our if else of al statements. Well, the loop is essentially a way to execute multi execute lines of code or a line of code multiple times. Digital media agencies in Mumbai Even though we might only actually write the code once.

OK, so this comes in particularly handy when we're dealing with doing the same repetitive task. Lots and lots of times particularly when using stuff like arrays. They have really loops of really well with arrays because it's a nice easy way to iterate over every element within an array. We'll get some loops and arrays in a little bit. Let's first talk about just a basic while loop because arrays and loops go really well together. So a while loop actually starts off looking a lot like it is statements.

But instead of only executing the code inside once an X is saying we're going to execute the code over and over again until the test fails. OK so let's consider this example might be a bit silly but perhaps we have some kind of an endpoint. We have a starting point and we're trying to see how far it is to get to that point.

Now the simplest way obviously would be to get the end value get the stock value and just subtract them and that would give you the number of steps you have to take to get to from point A to Point B. But let's assume that we wanted to actually print out our progress as we go. And besides, there might be other obstacles in the way that might be may have to backtrack or something.

So it's not always apparent exactly how many steps we need to take. So what we'll do is start out with endpoint variables that call this endpoint. This is just going to equal to or something. OK. We should have a start point. Start points here let's just set the sequel to three arbitrarily. And our goal here again is to reach from start point to endpoint and again print our progress as we go.

  • Love
  • Save
    Add a blog to Bloglovin’
    Enter the full blog address (e.g. https://www.fashionsquad.com)
    We're working on your request. This will take just a minute...