If Statement

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome my name is Logan aka Cody don't care 101 and today's algorithm video tutorial I will be showing you how to use the if statement inside of liver which is located under control so on this you have a true in a false side and how the if statement works it will only trigger if something is true so if X is less than 10 or if X is greater than however you want to word it if that is true it will go down the true side if it isn't or elves as you'll see in later programming in software it will go down the false side here so the best way to think of this if some if if something is true it will happen else either it will not do anything or it will do a separate function so where you are going to create a small program that will calculate tip based off being real price so first we will declare and we want a real number the water clear guilt next we'll do another to declare and we will do total bill and when this will also be a real number we'll hit OK and then finally our last to clear will be tip and this is also a real number so next we need an output and inside this output we will say how much is the deal boy ok and now this is where we get our input from the user bill so with this now we have the price of the bill this is where we will put our if statement right after all right input so we'll do it in sight and then side here if the bill is less than $25 there's about we will type in so if the bill is less than $25 it would just going to come down the true side right here if it isn't it would come down the false side so on if statements you want it to trigger untrue 90% of the time you want it to be untrue as much as you possibly can so make sure you word your condition right here we're able to go on the true side so we'll hit OK so it now will cap only gonna do in a sign what do you tip equals bill times 0.15 and the zero has to be here for Fugger rhythm in front of that decimal or else you'll get this error right here because it does not understand why you're putting a decimal in front of it without the zero sin and as soon as we put the zero it works so we're just gonna like copy this and paste it onto the false side but we'll also get a change it so step a point 0.15 we got to zero point two zero when we want hit okay no oh underneath this if statement we're gonna tell and we will do in a sign and he we will do little bill goes bill press yep and we'll hit okay and then we will do an output here our outfit will say word bill to a little of space dollar sign in quotes and total bill and okay and now when we run it we will do little $20 and we get $23 so let me type in my tech data right here so well yeah we did 20 times 0.15 which is 3 and 20 plus 3 is 23 so our math is correct on here so now if we run this again one go say the bill came to 30 dollars this time we'll hit enter now we have to pay $36 as a total bill and this fellow checked this bought the handy-dandy calculator and it's 30 times zero point two zero as that is our new bill price right here and BCE is total sick so when we add that back in charge $30 the tip the total bill is current at $36 as seen here now the if statement the if statement can be confused with the while loop which is very similar and they can use be used in a lot of the same places a while loop triggers multiple times as long as the condition is true whereas the if statement triggers only once and if you find yourself having trouble trying to figure out when to use which one talk yourself through this if you find yourself if you find yourself saying if this happens names to the time is an if statement and it simplifies a lot of the work you'll be doing that's all I have for you till next time and I will see you later
Info
Channel: CodingDoctor101
Views: 5,987
Rating: 4.8400002 out of 5
Keywords:
Id: hhAsxKaLK_A
Channel Id: undefined
Length: 6min 38sec (398 seconds)
Published: Wed Jul 10 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.