Skip to playerSkip to main contentSkip to footer
  • 5/22/2025

This code defines a function multiplication_table_of_two that takes an integer limit as input. It then iterates from 1 to limit (inclusive) and prints the multiplication of 2 with each number in the loop. The output will be the multiplication table of 2, up to the specified limit (10 in this case), formatted as "2 x i = 2 * i".

Category

📚
Learning
Transcript
00:00We will generate a table, so we will give a solution to this challenge.
00:03And we will do this because we have nested for loop power,
00:08so we will generate 2, 3, 4, 5, 6, 7, 8, 9, 10.
00:12It's totally no problem for us now.
00:14We know that we need to use nested for loop.
00:18I will generate a list and let's say 2.
00:21And where do we generate a table?
00:24Let's say 10.
00:25I will generate a list and let's say 2.
00:28And we will generate an element.
00:31That is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
00:36Like this.
00:37Okay.
00:38Now we can simply change this in a table.
00:42That is 2.
00:43The table is 1, 2, 2, 2, 2, 3, 4, 5, 6, and so on.
00:51This means I will nested for loop.
00:54For individual value of list 1, entire list 2 execute.
01:00Okay.
01:02For x in list 1, colon.
01:05For individual value, each individual value of list 1, entire list 2 run.
01:11To run, how should we use for?
01:12For y in list 2.
01:13Okay.
01:14And then what do we need to do this process?
01:15To run, how should we use for?
01:16For y in list 2.
01:17Okay.
01:18And then what do we need to do this process?
01:19What do we need to do?
01:20Now remember that we have x and y values available.
01:21So I simply multiply it by using print function.
01:23So I simply multiply it by using print function.
01:26Okay.
01:27x multiplied by y.
01:28However, if I print it by 2,
01:31then x divide by y.
01:32We have learned more about the string formatting.
01:34So we increase the aesthetic beauty.
01:37So I use f string.
01:39I will say x multiplied by y.
01:44The value is equal to this value.
01:49then this value
01:52okay
01:54yeah
01:56is equal to
01:57simple
01:57we have equal to
01:58assign
01:58just to make it more
02:00compact
02:00totally fine
02:02okay
02:03so let's execute
02:04and we run it
02:06and we say
02:07201 is equal to
02:082
02:08202 is equal to
02:094
02:096
02:10and so on
02:11interesting enough
02:13that
02:14we can extend
02:16the table
02:16this is
02:16extend
02:17this is
02:17now
02:19I will just
02:20element or
02:21add
02:212
02:213
02:224
02:235
02:236
02:237
02:238
02:249
02:249
02:269
02:26and then there is a 3
02:39table
02:40then there is a 4
02:41table
02:41and
02:42so
02:42on
02:43congratulations guys
02:46I have to
02:46I have to
02:47mistake
02:47and I have to
02:48congratulate
02:48it is not
02:49congratulations
02:50you have written
02:52your first nested for loop
02:54code
02:56which you have to
02:57generate a table
02:58right
02:58cool
03:00so let's go here we have this lecture
03:01we have closed
03:02but before we go
03:05I have a little question
03:07I have to say
03:08this is 9 to the table
03:10generated this is 100 to the table
03:11scalability is very important
03:15never expect
03:16that you have a limited number of list
03:18which you have 1, 2, 3 and ABC item
03:20and you have to perform some code
03:22and you will get your job done
03:24life is not like this
03:25now if you have a list
03:28let's say 100 element list
03:30how do we do it
03:31so this is the range function
03:34which automatically
03:35will generate lists
03:36in the next lecture
03:39we will start with range
03:39in the next lecture

Recommended