All language subtitles for 2. Print Rectangle of Asterisks - 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
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,950 --> 00:00:01,760 Welcome back. 2 00:00:01,970 --> 00:00:09,980 So I hope you've tried and solved this exercise successfully, and what we are going to do now is simply 3 00:00:09,980 --> 00:00:11,750 do this exercise together. 4 00:00:12,140 --> 00:00:18,650 So get yourself ready and make sure you check out everything you've written on your own and that everything 5 00:00:18,650 --> 00:00:20,690 seems to be working correctly. 6 00:00:21,500 --> 00:00:27,560 So now what we are going to do is simply to remove these print offline, because we know, first of 7 00:00:27,560 --> 00:00:31,580 all, that we have to print some pattern that just looks like this. 8 00:00:31,580 --> 00:00:31,850 Right. 9 00:00:31,880 --> 00:00:34,160 So, Dan, what is it? 10 00:00:34,160 --> 00:00:43,220 One five 10 asterisks are two in each row and we have a total of five rows just like that. 11 00:00:43,220 --> 00:00:44,990 So one, two, three, four or five. 12 00:00:44,990 --> 00:00:49,850 So that's the that's the pattern that we want to see printed on the screen. 13 00:00:49,850 --> 00:00:50,240 Right. 14 00:00:50,450 --> 00:00:57,380 Just like we've printed some numbers, we also can print some other characters just like these asterisks. 15 00:00:58,190 --> 00:01:00,720 And that's exactly what we are going to do right now. 16 00:01:00,740 --> 00:01:03,140 So what what do we have to do? 17 00:01:03,150 --> 00:01:03,710 First of all? 18 00:01:04,040 --> 00:01:11,710 First of all, we need to understand that we can do it in two ways and we can do it like to use a printing 19 00:01:11,840 --> 00:01:16,920 command to print each line, each line to print with ten asterisks. 20 00:01:16,930 --> 00:01:19,300 So, for example, it will look like this. 21 00:01:19,310 --> 00:01:27,260 So print f, print F simply all these function does is to take some, let's say, string for now, some 22 00:01:27,770 --> 00:01:34,700 bunch of characters and represent them and bring them to the screen so it will look something like this 23 00:01:34,700 --> 00:01:40,530 or print F and one, two, three, four, five, six, seven, eight, nine, 10. 24 00:01:40,550 --> 00:01:40,940 Right. 25 00:01:41,390 --> 00:01:48,290 So and then we will add the semicolon at the end to specify that this command is over and complete. 26 00:01:50,090 --> 00:01:56,840 All right, so we know that these come in printed just one line, so let's simply copy this line and 27 00:01:57,350 --> 00:02:00,540 printed once again five times, right. 28 00:02:00,560 --> 00:02:03,050 So we have here five rows. 29 00:02:03,740 --> 00:02:10,730 And the question is, is this pattern that we can see right now here on the screen, will it be printed? 30 00:02:10,730 --> 00:02:11,360 Exactly. 31 00:02:11,360 --> 00:02:14,750 Just like this if we will build and run this program? 32 00:02:14,760 --> 00:02:16,730 So let's build and check it out. 33 00:02:16,730 --> 00:02:18,140 So build and run. 34 00:02:19,010 --> 00:02:26,660 And you can see here on the screen that not we cannot see the whole pattern, although we can see a 35 00:02:26,660 --> 00:02:29,630 lot of asterisks printed through the screen right now. 36 00:02:29,630 --> 00:02:35,720 But it's not a lot of it's not actually the pattern of the rectangle that we wanted to print. 37 00:02:35,840 --> 00:02:38,100 All of them are printed in just one line. 38 00:02:38,870 --> 00:02:45,800 So one of the things that you have to understand is that after every printer here, we will use a backslash 39 00:02:45,800 --> 00:02:53,690 and character that simply specifies that we are going to go one line below in the printed result. 40 00:02:53,720 --> 00:02:55,070 So let's listen in. 41 00:02:55,100 --> 00:02:55,830 There you go. 42 00:02:56,090 --> 00:02:57,920 Let's build and run it once again. 43 00:02:57,920 --> 00:03:04,430 And we'll first of all, we had all of the characters, all of these 50 characters on just one line. 44 00:03:04,730 --> 00:03:11,600 And now hopefully we will see that pattern that we were expected by using these backslash m so these 45 00:03:11,600 --> 00:03:15,140 backslash and you can see it right here after ten characters. 46 00:03:15,140 --> 00:03:22,250 After all of these characters, there is a new line printed on this console application and after another 47 00:03:22,250 --> 00:03:24,620 attempt asterisks a new line again. 48 00:03:24,620 --> 00:03:26,120 And there you go again and again. 49 00:03:26,420 --> 00:03:33,800 And basically you can see that that's exactly the pattern and the rectangle that you expected to see 50 00:03:34,580 --> 00:03:34,790 in. 51 00:03:34,790 --> 00:03:44,390 One main question that students ask me later on in the Q&A section is why did we have to use here five 52 00:03:44,390 --> 00:03:45,710 printer commands? 53 00:03:45,710 --> 00:03:48,470 So basically, couldn't we just take it? 54 00:03:48,470 --> 00:03:55,240 And instead of using five printer commands, just combine all of them in just one print of command. 55 00:03:55,910 --> 00:03:58,210 So take a second and think about it. 56 00:03:58,580 --> 00:04:03,780 But the question is pretty obvious is that we can do it. 57 00:04:03,800 --> 00:04:11,930 So what we will simply do is just take every 10 asterisk and put them inside here and put it back in 58 00:04:12,230 --> 00:04:14,560 to an asterisk, a backslash n again. 59 00:04:14,870 --> 00:04:23,090 And finally and what we have done here is simply specifying in one print of command instead of using 60 00:04:23,090 --> 00:04:29,660 five, we simply specify that print have 10 asterisks after words print in your line. 61 00:04:29,660 --> 00:04:29,990 Right. 62 00:04:29,990 --> 00:04:37,550 Because we want to move a new line ahead and then print an asterisk once again, print a your line and 63 00:04:37,550 --> 00:04:39,350 there you go again and again and again. 64 00:04:39,350 --> 00:04:40,130 How many times. 65 00:04:40,460 --> 00:04:41,180 Five times. 66 00:04:41,180 --> 00:04:41,390 Right. 67 00:04:41,390 --> 00:04:45,440 Because we have five rows and we have ten columns in each row. 68 00:04:45,590 --> 00:04:47,950 And that's exactly what we are doing right here. 69 00:04:48,170 --> 00:04:53,680 So let's build and run it once again to make sure that everything seems to be working correctly. 70 00:04:53,690 --> 00:04:55,280 So there you go. 71 00:04:55,460 --> 00:04:59,560 There is our pattern and basically two options. 72 00:04:59,570 --> 00:05:08,690 You've seen how you can do it using five print F commands when each print off line simply represents 73 00:05:08,690 --> 00:05:16,430 one row in the pattern or how you can do it just by using one print off-line, using these combinations 74 00:05:16,850 --> 00:05:22,890 of properly putting these backslash and inside of the command itself. 75 00:05:23,660 --> 00:05:29,390 So I hope everything is clear, guys, and I hope you're ready for your next exercises. 76 00:05:29,570 --> 00:05:30,340 I'll see you then. 7370

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