All language subtitles for 6. Challenge 1 - Solution 2

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,420 --> 00:00:08,160 So basically, we were asked to write a program that will get as an input from the user to variables 2 00:00:08,280 --> 00:00:14,400 current year end users age and then make some calculations on these two variables. 3 00:00:14,610 --> 00:00:18,690 But let's leave that aside for now and just focus on the first part. 4 00:00:19,050 --> 00:00:24,210 We need to get as an input to values for our two variables. 5 00:00:24,450 --> 00:00:30,600 And then the previous videos, we've said that if we wanted to use variables in our program, then the 6 00:00:30,600 --> 00:00:34,320 first step to do is to create them, to declare them. 7 00:00:34,560 --> 00:00:37,230 So that's exactly what we're going to do right now. 8 00:00:37,260 --> 00:00:43,660 So let's first of all, declare these two variables gained current year. 9 00:00:43,830 --> 00:00:44,130 Right. 10 00:00:44,190 --> 00:00:45,330 It's the first variable. 11 00:00:45,670 --> 00:00:49,710 And let's declare also the age variable int age. 12 00:00:50,040 --> 00:00:52,290 Both of them are of type integer. 13 00:00:52,680 --> 00:00:55,980 The first name is current year and the second name is age. 14 00:00:56,220 --> 00:00:59,880 So at this point, these two variables are kind of empty. 15 00:00:59,910 --> 00:01:02,640 They contain no real value at this point. 16 00:01:03,060 --> 00:01:09,300 And one of the options to set their values is to use assignment and to give these values. 17 00:01:09,330 --> 00:01:11,520 I don't know something manually, for example. 18 00:01:11,850 --> 00:01:22,290 We can use current year, current year equals to 2020 and age equals to 30, as we used in our example. 19 00:01:22,990 --> 00:01:25,920 And that's exactly what we don't want to do. 20 00:01:26,400 --> 00:01:32,400 We should read these values from the user and not to sign them manually as we're doing here. 21 00:01:32,640 --> 00:01:37,250 So the first thing that we do is scan F, scan F, all right. 22 00:01:37,620 --> 00:01:41,690 Percentage the Y because we use two variables of type. 23 00:01:42,460 --> 00:01:48,230 And then we use a comma ampersand and current current year. 24 00:01:48,570 --> 00:01:48,900 Right. 25 00:01:49,350 --> 00:01:53,160 That's how we scan F as an input from the user. 26 00:01:53,430 --> 00:01:54,510 The current year. 27 00:01:55,380 --> 00:02:00,050 And also let's do the same for the age scan of percentage. 28 00:02:00,080 --> 00:02:02,820 The ampersand age. 29 00:02:03,600 --> 00:02:09,690 This once again, once again means the address where the variable age resides. 30 00:02:09,720 --> 00:02:10,170 All right. 31 00:02:10,180 --> 00:02:16,590 So take the value from the prompt from the console application, read it and put it inside of these 32 00:02:16,590 --> 00:02:17,340 variable. 33 00:02:17,520 --> 00:02:18,120 All right. 34 00:02:18,390 --> 00:02:22,830 So in this way, we'll be able to read these values from the user. 35 00:02:23,250 --> 00:02:25,030 So there are different. 36 00:02:25,050 --> 00:02:29,460 Users will be able to insert different values in a more generic way. 37 00:02:29,970 --> 00:02:37,060 So now at this point, at this line, at this line, for example, line twelve, after the two scan 38 00:02:37,060 --> 00:02:44,010 F lines and all that remains now is to calculate and print the results, to print the year you were 39 00:02:44,010 --> 00:02:45,510 born to the screen. 40 00:02:45,990 --> 00:02:49,170 So to bring something to the screen, we should use the print. 41 00:02:49,230 --> 00:02:50,700 The print if function. 42 00:02:50,730 --> 00:02:50,970 Right. 43 00:02:51,000 --> 00:02:51,660 Print F. 44 00:02:52,080 --> 00:02:52,530 All right. 45 00:02:52,560 --> 00:02:55,830 So what should be we should we be printing for this screen. 46 00:02:56,310 --> 00:02:59,260 So we should be printing something like that. 47 00:02:59,310 --> 00:03:06,210 You were born in percentage the backslash n right. 48 00:03:06,270 --> 00:03:07,660 To get one line down. 49 00:03:08,140 --> 00:03:13,290 And here we should use our expression to find out the exact year that you were born. 50 00:03:13,530 --> 00:03:17,440 And that could be done just by subtracting can be current. 51 00:03:17,790 --> 00:03:27,260 The age of the current year, current year minus age will give us the exact year that the user were 52 00:03:27,260 --> 00:03:28,230 born, was born. 53 00:03:28,530 --> 00:03:29,400 And there you go. 54 00:03:29,420 --> 00:03:35,350 Now we can build and run this program and see their results on the screen for ourself. 55 00:03:35,520 --> 00:03:37,710 So let's build it and run it. 56 00:03:37,900 --> 00:03:38,370 All right. 57 00:03:38,580 --> 00:03:44,320 So now let's place first of all, we need to enter the current year, for example, 2020. 58 00:03:44,920 --> 00:03:45,630 All right. 59 00:03:45,960 --> 00:03:53,160 And now the prompt waits for the age we should also put here at the age, let's say, as we've done 60 00:03:53,160 --> 00:03:56,280 in our example, 30, let's press enter. 61 00:03:56,700 --> 00:04:00,120 And now you were born in nineteen ninety nine. 62 00:04:00,330 --> 00:04:01,570 Oh, so that's cool. 63 00:04:01,590 --> 00:04:04,620 You can actually find the year that you were born. 64 00:04:04,890 --> 00:04:07,440 Let's try another example, let's say. 65 00:04:07,890 --> 00:04:08,160 All right. 66 00:04:08,670 --> 00:04:11,100 Let's say so. 67 00:04:11,130 --> 00:04:13,320 The year right now is 2020. 68 00:04:13,860 --> 00:04:16,900 And for example, you are 57 years old. 69 00:04:17,040 --> 00:04:18,430 Let's say 57. 70 00:04:18,630 --> 00:04:25,680 Press enter and we can actually find out at the year that, for example, your father or grandfather 71 00:04:25,680 --> 00:04:27,300 was who was born. 72 00:04:27,750 --> 00:04:30,460 You were born in 1963. 73 00:04:30,750 --> 00:04:31,260 Great. 74 00:04:31,540 --> 00:04:32,190 All right. 75 00:04:32,220 --> 00:04:34,890 So we've successfully completed our challenge. 76 00:04:35,370 --> 00:04:44,220 And by the way, some of you may have also tried some other ways, some other solution by using an additional 77 00:04:44,220 --> 00:04:48,420 variable to hold the calculated value of the birth year. 78 00:04:48,600 --> 00:04:52,710 So you probably used something like this after you declare a variable. 79 00:04:52,740 --> 00:04:57,150 Another variable called birth year. 80 00:04:57,590 --> 00:04:57,900 Right. 81 00:04:58,260 --> 00:04:59,730 And then before. 82 00:04:59,830 --> 00:05:06,110 You printed out something on your screen, you just use something like death, birth year equals to 83 00:05:06,110 --> 00:05:08,670 these to this guy, right? 84 00:05:08,810 --> 00:05:17,120 He goes to these guy and then instead of writing any mathematical expression here, you just use the 85 00:05:17,120 --> 00:05:18,610 birth year. 86 00:05:18,860 --> 00:05:19,170 Right. 87 00:05:19,430 --> 00:05:20,540 Something like that. 88 00:05:20,690 --> 00:05:22,320 And that's totally OK. 89 00:05:22,370 --> 00:05:23,990 You should work the same way. 90 00:05:24,380 --> 00:05:31,670 We simply previously didn't use any additional variable as opposed to this example where we created 91 00:05:31,760 --> 00:05:36,890 another temporary variable that helped us with this calculation. 92 00:05:37,160 --> 00:05:44,300 But if any of you solved the sex or size with the additional variable like we've seen here, there is 93 00:05:44,300 --> 00:05:45,440 nothing wrong with it. 94 00:05:45,590 --> 00:05:47,530 It simply will work. 95 00:05:47,540 --> 00:05:49,310 It will simply work the same way. 96 00:05:49,490 --> 00:05:52,010 So this is it, guys, for this video. 97 00:05:52,250 --> 00:05:55,400 I hope that everything runs on your side as well. 98 00:05:55,880 --> 00:05:56,160 Right. 99 00:05:56,210 --> 00:05:59,090 Relevant nodes for you from this challenge. 100 00:05:59,210 --> 00:06:06,590 Different examples, different ways we solve the sex or size and preparing herself for the next challenge. 101 00:06:06,770 --> 00:06:07,520 I'll see you there. 8595

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