Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,600 --> 00:00:01,900
What is going on, guys?
2
00:00:01,920 --> 00:00:06,450
And welcome back to another exercise in our programming course.
3
00:00:07,010 --> 00:00:14,490
In this video, we are going to talk again about loops and how we can use them in order to utilize and
4
00:00:14,490 --> 00:00:19,310
to create different patterns and to prevent different shapes to the screen.
5
00:00:20,190 --> 00:00:23,120
So get yourself ready and let's go.
6
00:00:23,940 --> 00:00:30,690
And what we have to do in this exercise is simply to write a program that receives an integer, which
7
00:00:30,690 --> 00:00:32,090
will be the variable.
8
00:00:32,130 --> 00:00:41,320
It's a variable in and in this exercise, we should print a pyramid of numbers with the following pattern.
9
00:00:41,340 --> 00:00:43,020
So basically it should look like this.
10
00:00:43,050 --> 00:00:46,710
We should start by specifying the number of rows.
11
00:00:46,770 --> 00:00:53,370
OK, this will be the number, number of rows.
12
00:00:53,610 --> 00:00:55,440
OK, the number of rows.
13
00:00:56,040 --> 00:01:00,940
And once we specify the number of rows, we should print the following pattern.
14
00:01:00,960 --> 00:01:06,180
So starting from one end on the second row, we will have two values.
15
00:01:06,210 --> 00:01:12,990
So in the first row, one value on the second row to value two values on the third row, three values
16
00:01:12,990 --> 00:01:14,400
and so on and so forth.
17
00:01:14,940 --> 00:01:22,830
So basically, starting with just this pattern from one in incrementing each value from the left to
18
00:01:22,830 --> 00:01:25,040
divide by one once again.
19
00:01:25,050 --> 00:01:27,110
So one, two, three, four or five, six.
20
00:01:27,870 --> 00:01:33,240
And also this should be printed like make sure you don't print it like this.
21
00:01:33,270 --> 00:01:40,620
So one, two, three, four, five, six, because this will be just the right angle triangle.
22
00:01:40,620 --> 00:01:47,640
And we I think we already talked about how to print this kind of shape, but rather, what do we have
23
00:01:47,640 --> 00:01:52,380
to do is simply to print it like these this pattern of triangle.
24
00:01:52,420 --> 00:01:59,850
So basically what you should think about is how you can know in advance what will be the number of spaces
25
00:02:00,000 --> 00:02:01,200
in each row.
26
00:02:01,260 --> 00:02:04,110
OK, so think about it, maybe two.
27
00:02:04,110 --> 00:02:07,110
That's this will be just one space and so on.
28
00:02:08,040 --> 00:02:10,320
And also how you increment the value.
29
00:02:10,500 --> 00:02:16,010
If these were just stories you, you know, we could have printed like this.
30
00:02:16,350 --> 00:02:17,640
So that's not a problem.
31
00:02:17,640 --> 00:02:24,600
We already have done something similar to this exercise, but now we want to print the numbers in some
32
00:02:24,600 --> 00:02:25,870
incrementing order.
33
00:02:25,890 --> 00:02:35,310
So from one to six, or if we take a look, if we have rows equals two rows equals to four, then in
34
00:02:35,310 --> 00:02:36,060
this case.
35
00:02:36,060 --> 00:02:37,010
Sorry about that.
36
00:02:37,020 --> 00:02:39,000
Let me just erase it.
37
00:02:39,000 --> 00:02:41,760
Rows equals to where is it?
38
00:02:41,760 --> 00:02:42,830
Where is the mouse.
39
00:02:42,870 --> 00:02:45,420
OK, rows equals to four.
40
00:02:45,960 --> 00:02:51,860
In this case, what we should print is once again on in the first line we should print something like
41
00:02:51,900 --> 00:02:57,210
adjust the value of one, two, three, four or five, six, seven, eight, 10, nine.
42
00:02:57,330 --> 00:03:04,560
OK, simply incrementing and in every line printing the exact number of values based on the line itself.
43
00:03:04,560 --> 00:03:10,280
So line number one, that one value line number two, two values and so on and so forth.
44
00:03:10,860 --> 00:03:18,180
So do a couple of minutes, think about the solution, try writing it down on your own in your ID and
45
00:03:18,180 --> 00:03:22,170
of course we are going to solve it together in the next video.
46
00:03:22,530 --> 00:03:24,390
So until then, good luck.
4435
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.