All language subtitles for 14. Exercise 1 - Number of characters in a file [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,960 --> 00:00:02,250 So welcome back. 2 00:00:02,280 --> 00:00:10,770 And now basically what we would like to do in this solution is simply given this text file, OK, we 3 00:00:10,770 --> 00:00:19,170 would like to read it and the way we are going to read it is using the F Getsy function to basically 4 00:00:19,170 --> 00:00:25,170 read character by character until we reach the end of the file. 5 00:00:25,470 --> 00:00:34,110 OK, so how will it look like we will create a pointer called FP, a pointer to file and we will use 6 00:00:34,110 --> 00:00:41,910 FP equals to f open reading these file then we will ask FFP does not equal to now. 7 00:00:42,480 --> 00:00:45,420 Then it means that the file was successfully opened. 8 00:00:45,750 --> 00:00:47,830 What would we like to do here? 9 00:00:48,300 --> 00:00:49,110 What do you think? 10 00:00:49,860 --> 00:00:56,570 If we use just one f getsy then probably what we are going to get is just one character. 11 00:00:57,030 --> 00:01:04,330 So we use Algazi, specify the pointer and let's create also additional variable to store our characters. 12 00:01:04,330 --> 00:01:06,930 So let's say Char Maija. 13 00:01:08,310 --> 00:01:13,000 We will say it like this, Maija equals to f getsy F.P.. 14 00:01:13,700 --> 00:01:18,190 So this will read the first character, but that's not something that we want. 15 00:01:18,230 --> 00:01:27,090 We want to basically on every iteration to read a character until some condition is met. 16 00:01:27,680 --> 00:01:29,110 And what is this condition? 17 00:01:29,540 --> 00:01:33,140 This condition is until we reach the end of the file. 18 00:01:33,260 --> 00:01:34,790 So how can we specified? 19 00:01:35,300 --> 00:01:36,660 Let's let me show you. 20 00:01:36,710 --> 00:01:44,840 So while while and we will say until we don't reach some condition, which is the end of file and we 21 00:01:44,840 --> 00:01:50,780 have these special EAF and a file specifying we reached the end of the file. 22 00:01:51,950 --> 00:01:57,620 So that's basically also take these Maija inside of these while statement. 23 00:01:58,100 --> 00:01:59,890 Don't don't get scared. 24 00:01:59,900 --> 00:02:01,430 It's not so complicated. 25 00:02:01,920 --> 00:02:05,060 So let's go like this. 26 00:02:05,520 --> 00:02:08,510 Let me explain you in just a second what we've done here. 27 00:02:08,570 --> 00:02:09,830 OK, no worries, guys. 28 00:02:10,880 --> 00:02:11,330 So. 29 00:02:12,580 --> 00:02:13,640 What do we have here? 30 00:02:14,050 --> 00:02:22,270 We have my car getting assignment and input from F. Getsy F.P., getting a character from the file one 31 00:02:22,270 --> 00:02:27,850 after the other and deles while until you reach the end of the file, that's it. 32 00:02:28,510 --> 00:02:32,410 Read a character from a file until you reach the end of the file. 33 00:02:33,400 --> 00:02:39,970 And on every iteration, what I want you to do is to print the character to the screen. 34 00:02:40,480 --> 00:02:41,590 So my char. 35 00:02:41,800 --> 00:02:42,580 My char. 36 00:02:43,690 --> 00:02:47,260 And that's basically all there is to it. 37 00:02:47,560 --> 00:02:52,990 OK, just we need to add the count, but I want to first of all, to run this program to show you that 38 00:02:52,990 --> 00:02:53,890 it works. 39 00:02:54,100 --> 00:02:57,180 OK, so hi, this is Vlad from Alphatech. 40 00:02:57,820 --> 00:02:59,200 And what can you notice here? 41 00:02:59,680 --> 00:03:09,580 You can notice that my getting character one at a time, it also gets characters like H e y and then 42 00:03:09,580 --> 00:03:14,890 he gets characters like space and then it also gets characters like Backslash N. 43 00:03:15,830 --> 00:03:21,650 Because if it wouldn't get the backslash and characters, the new line characters, then what would 44 00:03:21,650 --> 00:03:28,340 happen here is that all of the text from the file would be just in one line. 45 00:03:28,700 --> 00:03:33,710 And you can see that by using these print F percentage C and the backslash. 46 00:03:33,740 --> 00:03:38,600 And right here we jump to the next line, to the next line and so on and so forth. 47 00:03:38,730 --> 00:03:41,380 So the backslash was read carefully. 48 00:03:41,840 --> 00:03:45,440 And finally, I also wanted to create some counter. 49 00:03:45,440 --> 00:03:51,080 So end count of characters equals to zero. 50 00:03:52,070 --> 00:03:56,760 And in this case, every character we are going to count, it's a complex place. 51 00:03:57,200 --> 00:03:59,110 And finally, we will print. 52 00:03:59,120 --> 00:04:04,430 I don't know, the total of characters in the file. 53 00:04:06,680 --> 00:04:11,380 In the file is percentage, the backslash in percentage. 54 00:04:11,380 --> 00:04:14,570 They will be replaced by count of characters. 55 00:04:15,610 --> 00:04:16,460 And that's it. 56 00:04:16,690 --> 00:04:24,910 So let's run it and hope for the best, so, OK, here, we also need to get a better solution, right? 57 00:04:24,910 --> 00:04:29,920 Because at the end of the file, there is no backslash and it ends on just one line. 58 00:04:29,920 --> 00:04:32,320 So it will look like there's no here. 59 00:04:32,360 --> 00:04:32,780 Come here. 60 00:04:33,820 --> 00:04:40,210 There are a lot of characters in the file is 32 and if you will count them up, they should match, 61 00:04:40,210 --> 00:04:41,920 including the backslash and probably. 62 00:04:41,920 --> 00:04:42,290 Right. 63 00:04:43,090 --> 00:04:45,130 So, yeah, this is it for this video. 64 00:04:45,160 --> 00:04:46,880 Guys, thank you so much for watching. 65 00:04:46,900 --> 00:04:48,060 Keep on practicing. 66 00:04:48,070 --> 00:04:52,810 Keep on moving forward and you are bound to succeed until next time. 67 00:04:52,840 --> 00:04:53,670 My name is Vlad. 68 00:04:53,770 --> 00:04:54,510 I'll see you then. 6213

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