All language subtitles for 6. Print the Absolute Number - 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,940 --> 00:00:08,290 So what we want to do this exercise is to write a program that will receive some value, write value, 2 00:00:08,290 --> 00:00:13,650 and these programs should print the absolute value of this given number. 3 00:00:13,660 --> 00:00:19,920 So let's start then create our first variable and only variable for this exercise. 4 00:00:19,930 --> 00:00:22,580 And it's going to be, let's say, no. 5 00:00:22,840 --> 00:00:24,130 OK, so tandem. 6 00:00:25,060 --> 00:00:33,900 Then we are going also to read the value from the from the user and enter integer, whether it's true, 7 00:00:34,090 --> 00:00:39,430 whether it's positive or negative, positive or negative. 8 00:00:39,670 --> 00:00:46,520 OK, so either it's positive or negative and then the user is going to insert this number. 9 00:00:46,540 --> 00:00:53,380 We are going to use it to read it using this kind of function and store it inside now and now we are 10 00:00:53,380 --> 00:01:00,610 ready to make our basically logic and the main part of this exercise thing that we want to do. 11 00:01:00,970 --> 00:01:05,560 So we have num and num, maybe either positive or negative. 12 00:01:05,560 --> 00:01:05,920 Right. 13 00:01:05,920 --> 00:01:11,620 Just like we've seen in the examples before, and we want to print the absolute value. 14 00:01:11,660 --> 00:01:16,580 So what do you have to do is to think about these two options? 15 00:01:16,600 --> 00:01:17,950 OK, two scenarios. 16 00:01:17,950 --> 00:01:23,140 The first scenario is either the number is negative or the number is positive. 17 00:01:23,800 --> 00:01:30,580 And what differentiates between two of these scenarios, the question is very the answer is very simple. 18 00:01:30,580 --> 00:01:32,320 It's just these conditions. 19 00:01:32,320 --> 00:01:42,370 So if num if num is less than zero, Phnom is less than zero, then in this case we know that the number 20 00:01:42,370 --> 00:01:43,570 is probably negative. 21 00:01:43,570 --> 00:01:51,940 Right then in this case, what we should do is simply to print out, OK, the absolute value, the absolute 22 00:01:51,940 --> 00:01:57,700 value of the percentage of num ease its use here. 23 00:01:57,730 --> 00:02:02,300 Also percentage be then in this case, that's what we will have. 24 00:02:02,320 --> 00:02:06,460 So instead of the first percentage placeholder, what we will use is simply. 25 00:02:07,300 --> 00:02:13,450 And instead of the second percentage, since we know nothing is negative, for example, let's say minus 26 00:02:13,450 --> 00:02:18,490 three, then in this case we should multiplied by minus one. 27 00:02:19,030 --> 00:02:27,810 And if we do so, we know that minus multiplied by minus gives us final result of plus is correct. 28 00:02:28,330 --> 00:02:34,060 So we simply take minus one and multiply it by now. 29 00:02:34,510 --> 00:02:35,080 That's it. 30 00:02:35,380 --> 00:02:41,410 So whatever value num had at this point or gave this condition is true. 31 00:02:41,410 --> 00:02:48,820 It was definitely negative and if we multiplied by minus one then we turn it into some positive value 32 00:02:48,820 --> 00:02:55,660 and we can represent it is the absolute value of num so awesome. 33 00:02:56,200 --> 00:03:03,880 But if the result was false for this condition, then we know that the number itself is positive. 34 00:03:04,660 --> 00:03:08,440 So that now what we can do is simply print this message. 35 00:03:08,440 --> 00:03:16,690 The absolute absolute value of percentage is percentage. 36 00:03:17,020 --> 00:03:24,650 And in both of these cases we will use none and none without multiplying it by any other number. 37 00:03:24,670 --> 00:03:33,760 So very simple, just taking of a given number, checking if it's positive or negative and if it's negative, 38 00:03:33,760 --> 00:03:39,040 multiplying it by minus one and if it's positive, multiplying it by nothing. 39 00:03:39,200 --> 00:03:42,900 OK, so simply that's how it's going to work. 40 00:03:42,910 --> 00:03:47,660 So let's build and run it and let's see what happens if we insert five. 41 00:03:47,680 --> 00:03:55,870 So the absolute value of five is five and if we will use like minus 17, then the absolute value of 42 00:03:55,870 --> 00:04:02,020 minus 17 is 17 since we multiplied it by minus one and that's it. 43 00:04:02,950 --> 00:04:07,360 So yeah, I think that everything is clear in this video. 44 00:04:07,360 --> 00:04:12,430 If you still have any questions, feel free to ask them in the questions sections. 45 00:04:13,690 --> 00:04:16,630 And until next time, have a great day. 4831

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