All language subtitles for 8. Challenge 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
hu Hungarian Download
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,390 --> 00:00:03,780 OK, so let's solve these exorcize together. 2 00:00:03,900 --> 00:00:10,050 And basically what we want to do is, first of all, to create our two variables in NARM and PEARLED. 3 00:00:11,160 --> 00:00:18,060 So we created two variables that we'll hold for two values that we're expected to receive from the user 4 00:00:18,120 --> 00:00:20,340 a number and its power. 5 00:00:20,490 --> 00:00:22,950 So let's just read them from the user. 6 00:00:23,070 --> 00:00:28,410 Answer a number and then we are going to read these numbers. 7 00:00:28,440 --> 00:00:35,250 So percentage read this number and we are doing also the same for the power. 8 00:00:35,310 --> 00:00:37,050 Enter a power. 9 00:00:37,270 --> 00:00:37,780 All right. 10 00:00:38,370 --> 00:00:41,310 And read it inside of a variable. 11 00:00:41,500 --> 00:00:48,810 Now, what I want us to do is simply to understand that just we we are we cannot use it like this one. 12 00:00:48,840 --> 00:00:49,240 All right. 13 00:00:49,260 --> 00:00:51,060 We cannot use it like percentage. 14 00:00:51,660 --> 00:00:56,760 And here specify Nahm multiplied multiplied by Nahm multiplied by num. 15 00:00:56,930 --> 00:00:57,240 Right. 16 00:00:57,970 --> 00:01:00,810 It simply will not give us the solution that we want. 17 00:01:00,930 --> 00:01:05,940 We want to multiply num by num num just two times. 18 00:01:05,970 --> 00:01:06,360 All right. 19 00:01:06,390 --> 00:01:07,590 Two or three times. 20 00:01:07,620 --> 00:01:09,990 We wanted to be multiplied by num. 21 00:01:10,440 --> 00:01:11,910 How how many times. 22 00:01:12,030 --> 00:01:15,810 The exact time that is specified in this variable minus one. 23 00:01:15,870 --> 00:01:16,170 Okay. 24 00:01:16,620 --> 00:01:19,800 This is the whole structure of the mathematical power operation. 25 00:01:19,890 --> 00:01:22,440 So for that we are going to use loops. 26 00:01:22,500 --> 00:01:22,800 Right. 27 00:01:22,830 --> 00:01:25,300 We are already experts in using loops. 28 00:01:25,380 --> 00:01:30,360 So we should use loops in in order to solve this exercise. 29 00:01:30,810 --> 00:01:38,610 Although there is another way to include some other math library, but we are not familiar with it yet. 30 00:01:38,700 --> 00:01:45,110 So we will just use the tools that we already sell, already studied in this course. 31 00:01:45,270 --> 00:01:52,240 And before we use loops, we should also create some assisting guide variable that will hold the result 32 00:01:52,240 --> 00:01:52,890 so far. 33 00:01:52,950 --> 00:01:57,760 So we will create another variable called int result result. 34 00:01:58,230 --> 00:02:01,500 And we'll just give it a an initial value of one. 35 00:02:01,890 --> 00:02:09,420 And I'm initialize and get by with one because every number in the power of zero will at least give 36 00:02:09,420 --> 00:02:10,200 us one. 37 00:02:10,350 --> 00:02:10,710 Right. 38 00:02:10,980 --> 00:02:14,130 If it's not the power of zero, it will give us one. 39 00:02:14,160 --> 00:02:17,610 If it's nomine the power of one, it will give us num. 40 00:02:17,880 --> 00:02:20,190 So the minimum value is one. 41 00:02:20,280 --> 00:02:25,240 So that's why I'm going with this is our default as our starting point value. 42 00:02:25,490 --> 00:02:27,780 And I want to create a while loop. 43 00:02:28,050 --> 00:02:29,560 So we will use while. 44 00:02:29,910 --> 00:02:33,210 And now we will specify you there of the loop condition. 45 00:02:33,330 --> 00:02:35,030 So as long as po. 46 00:02:35,320 --> 00:02:35,760 All right. 47 00:02:35,790 --> 00:02:38,770 As long as the power is greater than zero. 48 00:02:39,090 --> 00:02:41,510 We are going to execute the Loopt body. 49 00:02:41,640 --> 00:02:47,070 And in the loop, we know that the result will hold the values so far. 50 00:02:47,190 --> 00:02:48,510 Meaning give the power. 51 00:02:48,900 --> 00:02:51,000 Let's say let's take let's take an example. 52 00:02:51,300 --> 00:02:58,320 If num was equal to would be equal to two and the power will equal to three. 53 00:02:58,920 --> 00:03:01,270 We are going to multiply num by that. 54 00:03:01,290 --> 00:03:02,250 Multiplied by now. 55 00:03:02,250 --> 00:03:03,360 Multiplied by num. 56 00:03:03,510 --> 00:03:06,270 So which will look something like that right now. 57 00:03:06,270 --> 00:03:08,490 Multiplied by Nahm, multiplied by narm. 58 00:03:08,700 --> 00:03:09,780 Would you give us two. 59 00:03:09,810 --> 00:03:10,890 Multiplied by two. 60 00:03:10,920 --> 00:03:13,050 Multiplied by two and a total of eight. 61 00:03:13,170 --> 00:03:20,280 So we are going here and we are going to execute this while loop and to add on each iteration the result 62 00:03:20,280 --> 00:03:23,250 of num by number multiplied by num. 63 00:03:23,520 --> 00:03:30,330 And then take this resolved and these value of this multiplication will be inserted in this variable. 64 00:03:30,960 --> 00:03:36,810 And then we are going to repeat this process to take these results so far multiplied by NUM. 65 00:03:36,870 --> 00:03:44,310 And once again, story inside the result variable until until we reach that this condition is false. 66 00:03:44,400 --> 00:03:51,210 So let's see how it looks like we specify the variable resolved equals to the previous result to the 67 00:03:51,210 --> 00:03:53,190 result calculated so far. 68 00:03:53,310 --> 00:03:53,710 All right. 69 00:03:53,730 --> 00:04:00,900 On every duration we multiply by another and another num and multiplied by num. 70 00:04:00,930 --> 00:04:03,570 So the previous result multiplied by num. 71 00:04:03,750 --> 00:04:08,660 You could also write it like this in just less syntax. 72 00:04:08,670 --> 00:04:13,210 Let's say resolved equals two, the previous result multiplied by nine. 73 00:04:13,590 --> 00:04:15,390 This is the same as we've written here. 74 00:04:15,390 --> 00:04:17,370 I think it's more clearer to you guys. 75 00:04:17,520 --> 00:04:18,010 All right. 76 00:04:18,030 --> 00:04:26,070 So now what we want to do, if we will run it like this, we know that the power variable will always 77 00:04:26,070 --> 00:04:29,340 remain as is as we've read it here from the user. 78 00:04:29,430 --> 00:04:33,840 And it will simply be an infinite loop, although nothing will be printed on the screen. 79 00:04:33,870 --> 00:04:36,210 But still, the loop is going to be infinite. 80 00:04:36,240 --> 00:04:36,480 Right. 81 00:04:36,510 --> 00:04:41,670 Because these conditions will always remain true and nothing will kick us out of this loop. 82 00:04:41,880 --> 00:04:47,430 So for that, we will just reduce the power by one on every duration. 83 00:04:47,430 --> 00:04:47,730 Right. 84 00:04:47,970 --> 00:04:55,140 Because if we multiply here num by one, num by num and then by num, once again we know that we are 85 00:04:55,140 --> 00:04:58,220 doing it in the variable power. 86 00:04:58,260 --> 00:04:59,880 Here is three minus one. 87 00:05:00,000 --> 00:05:00,350 Times. 88 00:05:00,420 --> 00:05:02,160 So just a total of two times. 89 00:05:02,550 --> 00:05:09,540 And once we are done, we know that once we are out of this loop of this body loop, we are going to 90 00:05:09,540 --> 00:05:15,570 having the result variable, the result of numb in the power of these given power. 91 00:05:15,810 --> 00:05:19,080 And now all that remains is simply to print out the resolve. 92 00:05:19,410 --> 00:05:19,770 All right. 93 00:05:19,800 --> 00:05:22,440 So let's printing nice nice result of the screen. 94 00:05:22,680 --> 00:05:29,820 So percentage the aid will be the number in the power off and these will be the power that the user 95 00:05:29,820 --> 00:05:32,730 inserted equals to percentage. 96 00:05:33,840 --> 00:05:34,240 All right. 97 00:05:34,260 --> 00:05:34,920 And a backslash. 98 00:05:34,980 --> 00:05:36,140 And at the end. 99 00:05:36,450 --> 00:05:39,430 So here we specify for these first percentages. 100 00:05:39,840 --> 00:05:42,390 We specify a num num. 101 00:05:42,510 --> 00:05:44,180 And then we specify the ball. 102 00:05:44,280 --> 00:05:48,490 And then we specify for this result the result variable. 103 00:05:48,600 --> 00:05:52,460 It now holds the result of all of these calculation. 104 00:05:52,620 --> 00:05:54,750 And now I think we are ready to go with. 105 00:05:54,810 --> 00:05:57,330 I think that we can build and run these programs. 106 00:05:57,510 --> 00:06:00,390 Let's save it and click the build and run button. 107 00:06:00,540 --> 00:06:01,110 All right. 108 00:06:01,140 --> 00:06:05,730 So let's let's try our previous example that we used here, too. 109 00:06:05,910 --> 00:06:07,650 And the power will be three. 110 00:06:07,860 --> 00:06:13,230 So we expect to see the result of two multiplied by two, which is four, and then multiplied once again 111 00:06:13,230 --> 00:06:17,010 by two, which give us a total result of just eight. 112 00:06:17,040 --> 00:06:20,110 So two in the power of zero. 113 00:06:20,190 --> 00:06:20,540 Oh. 114 00:06:20,670 --> 00:06:21,510 What happened here? 115 00:06:21,570 --> 00:06:22,170 Let's see. 116 00:06:22,290 --> 00:06:29,190 So we can see that basically the power that we tried to bring here is now seems to be zero. 117 00:06:29,190 --> 00:06:29,490 Right. 118 00:06:29,520 --> 00:06:33,150 If we run it once again, it doesn't matter which power we insert here. 119 00:06:33,200 --> 00:06:35,430 Let's say five in the power of three. 120 00:06:36,060 --> 00:06:38,070 It still gives us at the end. 121 00:06:38,070 --> 00:06:38,390 Right. 122 00:06:38,430 --> 00:06:40,250 The calculation the result is, OK. 123 00:06:40,710 --> 00:06:43,920 Instead of these percentages, we can see that the number is five. 124 00:06:43,950 --> 00:06:46,650 But still, it gives us the power of zero. 125 00:06:46,660 --> 00:06:47,910 And why is there. 126 00:06:47,940 --> 00:06:48,480 Why is that? 127 00:06:48,900 --> 00:06:50,790 And the reason for that is very simple. 128 00:06:50,910 --> 00:06:57,810 It's because during these while operation, during this wire loop will reduce the value inside of the 129 00:06:57,810 --> 00:07:00,840 power variable on every duration. 130 00:07:00,870 --> 00:07:03,840 So we only leave these wire loop. 131 00:07:04,000 --> 00:07:07,810 When the power equals to zero or it's less than zero. 132 00:07:08,190 --> 00:07:11,460 In Dinara case, it will be just one equals two zero. 133 00:07:11,610 --> 00:07:17,490 So we if we still want to print these nice little message, we should maybe create another variable 134 00:07:17,490 --> 00:07:19,740 that will hold the power itself. 135 00:07:20,490 --> 00:07:23,940 In case that we change the power variable. 136 00:07:24,070 --> 00:07:24,300 Right. 137 00:07:24,310 --> 00:07:31,740 So we can create some in temp timbale that will hold the value of power before we are getting into these 138 00:07:32,460 --> 00:07:34,820 wire loops of tempo temp. 139 00:07:35,360 --> 00:07:42,000 Paul will be equal to now before it has been changed in these while loop in here. 140 00:07:42,000 --> 00:07:45,260 We will also changing to ten ten now. 141 00:07:45,700 --> 00:07:49,740 And now let's try to save it and run and build and running once again. 142 00:07:50,010 --> 00:07:52,110 So two in the power of three. 143 00:07:52,470 --> 00:07:58,410 And we see the exact message that we expect it to in the power of three gives us an eight. 144 00:07:58,800 --> 00:08:01,290 And we also could use it like this one. 145 00:08:01,470 --> 00:08:01,830 Right. 146 00:08:02,230 --> 00:08:12,190 Is the sign which represent in some cases, in some cases, it represents the power in some kulka literacies, 147 00:08:12,720 --> 00:08:13,770 to be more clear. 148 00:08:13,860 --> 00:08:17,880 So if we run it once again, let's do it with five and three. 149 00:08:18,150 --> 00:08:21,360 And we can see that five in the power of three equals two. 150 00:08:21,360 --> 00:08:22,890 One hundred and twenty five. 151 00:08:23,010 --> 00:08:25,230 So this is a four of these video guys. 152 00:08:25,410 --> 00:08:31,890 I think that your calculator is getting more more attractive and with much more functionality to it. 153 00:08:32,010 --> 00:08:36,120 And thank you guys for watching and I'll see you in the next video. 154 00:08:36,330 --> 00:08:36,690 Bye. 13133

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