All language subtitles for 23. Nested Loops - Print Right Angle Triangle Pattern - part 2 - Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So let's start solving this exercise, and I'm just getting the template from the solution of the previous

video where we talked about what was it?

It was something like this or printing the following pattern.

Right.

Let's just make sure that it's exactly what I'm talking about.

So let's go with the council.

Let's use and equals the three.

Yes.

So we printed out one, one, two, one, two, three.

And what we want to do in these exercises is the little we modify the pattern itself.

It's still going to be a right angle triangle, but the pattern of the values at each line is going

to be slightly different.

So here we have the template of the code from our previous exercise.

And let's simply start thinking about what should be modified in this solution so that this way we may

satisfy these conditions.

So what will happen?

We need to print the value of one just one time on the first row and the value of two, two times on

the second row and three and so on.

So we need here, let's say that we have like I is already equals to two.

And then in this case, we need to print.

We need to be equal to to write in printed two times.

So we need to print the value with say we need to print the value of I write because I equals to two

and we need to run this operation just two times.

So that's OK.

We will run it time.

So J no, it doesn't matter what is the value of J.

Of course J will be will start from one.

Right.

That's the initialise phase and will run up to AI which is two.

OK, so J will run two times and we will print the value of AI.

OK, ok.

I think we are getting closer so I'm not sure that that's the final solution.

But let's try to build and run it OK.

And see what happens.

OK, so that's also one way of working.

It's not usually recommended and like to build and run it when you are not sure for a hundred percent

that that's your optimal solution.

But sometimes when we have very similar exercises, for example, like this exercise is very similar

to the previous one, then in this case, I'm I'm giving you the option to to do this.

So let's run here three.

And yeah, basically we can see that everything works correctly and we have here the value of one,

two, two, three, three, three.

And let's just make sure that if we used different values, everything seems to be working correctly.

So one, two, two, three, three, three.

And basically, yeah, everything seems to be working just perfect.

So, yeah, another option that some of you probably thought about is maybe to use it for a loop in

inside of these for a loop to use a while loop.

So that's also an option.

And let's think about how it can be used.

So we need to print AI the value of ay ay times.

Right.

So we can say that let's say J equals to J equals to.

I write and we will say as long as J is greater than than zero, then in this case we will print the

value of Pi.

So let's go like this in here, specify the value of AI.

So let's see what happens and let's go with the value of five.

Then we have a problem.

So let's find what is, what is the problem.

So it's probably an infinite loop.

Right.

And we know that in this case.

In this case, we know that the value of G will be forever greater than zero and the slope will be executed

always.

So what we need to do is just to try using J minus minus.

So let's build and run it once again.

Click on this button and let's see what will happen.

So now let's go like five in here.

There you go.

You can see your solution on the screen once again.

Let's run it again with another value and see that it's working exactly as we expect.

Yeah.

Basically, that's the pattern that we expected it to be.

And you guys, this is it for this video.

We introduced the concept and talked about the concept of for loops inside of four loops, basically

using nested loops.

And we also saw how we can take an inner loop of while into use it inside for a loop and how we can

take it for a loop and use it inside of an.

For aloof and also there is no problem using a while loop inside of a while loop.

But one thing that you need to take to to bear in mind is that there should be some reason, some logic

behind this usage.

OK, there there will be no not all the exercises require you to use nested loops, but some of the

exercises will require you this knowledge and understanding of using nested loops.

So once again, make sure you understand everything.

And if you still have some questions, feel free to ask them.

And yeah, until next time, guys.

Good luck.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.