Welcome everyone to the program. So today, I will teach you for loop and using that for loop. I will be creating multiplication table. Okay. So first I'll write t equal to input what table do you want? Okay.
And now after this, I need to convert this T to integer. So t is equal to int of t. Otherwise we cannot perform arithmetic operation. Next, I'll write, print. Look carefully what I'm typing. So T, comma within quotes Have to give a multiplication sign. So this is a multiplication sign that I'm providing.
Then again give a comma and write one equal to and this equal to sign should be within quotes equal to comma. So t multiplied by one, so this should be the case. So now close this bracket and run this code. See what happens there is an error. Why did this is an error? Because again, have forward to give the comma here.
So now run this code and see it's asking what table Do you want suppose I want the table 10. So write 10 and press enter. So what it gives 10 Kwanza 10 that is 10 plus one is equal to 10. Now copy this code paste Here, and I just copy the last statement and paste it here and just change the one to two. And then here to again see what you got 10 cross one is equal to 1010 cross two is equal to 20. So this is basically our syntax what am following is nothing but a simple program.
Now if you want to increase the same thing, so just in place of this right tree, see what I'm getting. Now I have to type multiple times this print statement. Now using the for loop, this work can be easily solved. So what I'll do is I'll use a for loop. So t Input what table do you want? Now here I will convert it to integer again.
So by mistake I run the code, okay, so here I'll again write print sorry not print after use a for loop here now, so far i in range. So I'm writing 10. Now write, print, T, give comma. Now I have to give the sign multiplication then Give a comma here and in place of this numbers that is 123 right over here. So I, comma, again have to give equal to sign. If comma, and then here what I'll write t multiplied i.
So here I've replaced an individual number with I, because here I has a range of 10 in the for loop. So now just execute the code. So here, I'll execute the code. And it's still executing, because a star son is over here. See the star sign is we're humans, still executing the code. So don't do anything.
We need to wait Unless it's complete executing. So now it's asking for the number that is what table Do you want. So I'm writing 10. And now press enter. So, you're writing 10 and press enter and see what you got. You got that table of 10.
But here you have got up to nine because it's starting from zero because follow always start from zero. So here I'm just increasing the range and the range to 11. Then run it, give the number and see what you got. You got the table of 10. Now if you want a different table, then just execute it and ask for any number. See, any number tables you will get Now suppose I want So 20 number two is this.
So, in this way basically what we are doing here is we are converting a simple iteration to a program and see how easy it is just to convert a little bit of this particular iteration to the program and you can generate any number of table very easily and quickly. Now, here we do not have to repeat this particular statement several times, we can just provide it once and give a range in the for loop and it will execute automatically until all the range are written So, in this way you can get any number of table starting from zero to any number hundred thousand anything. So, I think this is enough for the for loop to you all and it'll start with the why loop. So in our next video, we'll be starting with a while loop and Practicing Then see you for the next video. Bye