Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,910 --> 00:00:07,950
So let's start solving these exercises together and we will simply print a nice message to the user
2
00:00:08,320 --> 00:00:10,350
so it will go something like this.
3
00:00:10,360 --> 00:00:15,730
So print enter a three digit number.
4
00:00:15,760 --> 00:00:24,070
OK, so then the user is going to insert his number and we need to store it inside of, let's say in
5
00:00:24,090 --> 00:00:24,510
some.
6
00:00:24,850 --> 00:00:31,990
So print F, enter a three digit number and read it using this kind of function and store it using the
7
00:00:31,990 --> 00:00:36,820
percentage placeholder stored inside the variable name.
8
00:00:37,390 --> 00:00:39,970
So that's basically the first step.
9
00:00:40,610 --> 00:00:46,270
And now that we have to do, we will assume that the user will not insert, you know, five or ten or
10
00:00:46,420 --> 00:00:49,850
ten thousand so that the calculations will be OK.
11
00:00:50,200 --> 00:00:58,580
And now what we have to do is to calculate from this naoum to extract the units, the tens and the hundreds.
12
00:00:59,740 --> 00:01:05,810
So for that, we have to create for example, let's say there are three additional variables.
13
00:01:05,830 --> 00:01:07,340
Of course, it's not mandatory.
14
00:01:07,360 --> 00:01:11,820
We can also just use it all of these calculations in the printing line.
15
00:01:12,070 --> 00:01:13,800
But still, I would like to do that.
16
00:01:14,050 --> 00:01:20,670
So let's do it like this in two units, towns and hundreds, hundreds.
17
00:01:21,640 --> 00:01:27,460
And now let's say we had our example like five, three, one.
18
00:01:27,760 --> 00:01:31,420
So in this case, we know that units will be equal to one.
19
00:01:31,720 --> 00:01:38,560
Tannen's will be equal to three and hundreds on the brands will be equal to five.
20
00:01:38,740 --> 00:01:41,490
OK, just like that.
21
00:01:42,370 --> 00:01:46,890
And now what we have to understand is simply to take this information.
22
00:01:46,900 --> 00:01:54,590
OK, so we know that units will be equal to one, which is the rightmost digit in a three digit number.
23
00:01:54,970 --> 00:01:58,900
So how should we get the units out of this number?
24
00:01:58,920 --> 00:01:59,860
What do you think, guys?
25
00:02:00,110 --> 00:02:03,580
Take a second to think about it and pause the video.
26
00:02:03,580 --> 00:02:11,620
And once you're back, let's continue to talk about it so the units can be calculated in a very easy
27
00:02:11,620 --> 00:02:12,220
approach.
28
00:02:12,490 --> 00:02:20,500
We can say that if we take this number and we use a remainder and divided by 10, for example.
29
00:02:20,500 --> 00:02:20,890
Right.
30
00:02:21,310 --> 00:02:24,560
Then if we just divided by 10, we will get 53.
31
00:02:24,740 --> 00:02:31,300
OK, but if we divide it with the remainder by 10, we will simply get the remainder of the division
32
00:02:31,300 --> 00:02:34,070
operation of five hundred thirty one by ten.
33
00:02:34,450 --> 00:02:36,340
So it will be simply one.
34
00:02:36,370 --> 00:02:41,670
So we simply take none and use the remainder divided by 10.
35
00:02:41,680 --> 00:02:45,070
So units equals to num modulo tenth.
36
00:02:45,940 --> 00:02:50,830
And now what we have to do is for example, to let's calculate the hundredths.
37
00:02:50,860 --> 00:02:57,130
So the hundredth is the leftmost digit and the hundredth is how many hundreds.
38
00:02:57,130 --> 00:02:57,900
Full hundreds.
39
00:02:58,060 --> 00:03:00,640
Do we have in a three digit number.
40
00:03:01,090 --> 00:03:02,680
And that's also not complicated.
41
00:03:02,690 --> 00:03:06,320
You simply take num in divided by 100.
42
00:03:06,610 --> 00:03:11,200
So how many full hundreds will get into num.
43
00:03:11,690 --> 00:03:14,140
This will be the hundred digits.
44
00:03:14,350 --> 00:03:20,500
OK, so in this case if we divide five three one by one hundred we will get five.
45
00:03:20,620 --> 00:03:23,370
OK, so units we got it on rest.
46
00:03:23,380 --> 00:03:24,000
We got it.
47
00:03:24,280 --> 00:03:29,480
The only thing that remains for us to calculate is the Tannen's digit.
48
00:03:30,460 --> 00:03:33,700
So how basically should you approach it?
49
00:03:34,600 --> 00:03:40,540
So there are actually a couple of ways to calculate it, to calculate this middle digit.
50
00:03:40,900 --> 00:03:43,960
One of the ways is simply to do the following.
51
00:03:44,200 --> 00:03:48,350
Let's say if we take five, three, one and divided by 10.
52
00:03:48,520 --> 00:03:54,520
OK, so for example, if we divide it by 10, we will get what will we get?
53
00:03:54,520 --> 00:03:57,070
We will get fifty three.
54
00:03:57,310 --> 00:03:57,700
Right.
55
00:03:58,120 --> 00:04:03,730
And if we have fifty three, we know how these rightmost character can be calculated.
56
00:04:03,760 --> 00:04:04,060
Right.
57
00:04:04,060 --> 00:04:05,380
Just by using this model.
58
00:04:05,380 --> 00:04:08,540
Lutin the remainder of the division by ten.
59
00:04:09,070 --> 00:04:17,220
So we simply may say that Towne's will be equal ok to num num num divided by ten.
60
00:04:17,380 --> 00:04:23,130
OK, which will give us the total amount of full 10th that this number represents.
61
00:04:23,620 --> 00:04:31,470
And this value will simply use a remainder of ten to find the right most digit inside of it.
62
00:04:31,990 --> 00:04:33,100
So I hope that's clear.
63
00:04:33,460 --> 00:04:41,470
You have to find the units of tens and the hundreds and now all that is left for us to do is simply
64
00:04:41,470 --> 00:04:43,570
print the result to the screen.
65
00:04:44,410 --> 00:04:47,630
So how will you do it using the printed function?
66
00:04:47,980 --> 00:04:56,860
The total sum of digits in percentage in a given NUM is percentage.
67
00:04:57,880 --> 00:05:00,340
So the first percentage of the first place home.
68
00:05:00,410 --> 00:05:07,350
There is the numb, right, because we describe it so now and afterward, and we have another tragedy,
69
00:05:07,730 --> 00:05:15,920
which will simply be the sum of units, tens and hundreds, which will be just like this, tens and
70
00:05:15,920 --> 00:05:20,060
hundreds, hundreds and hundreds.
71
00:05:20,160 --> 00:05:22,220
OK, semicolon in the end.
72
00:05:22,760 --> 00:05:27,090
So let's try to build and run it and see what happens.
73
00:05:27,230 --> 00:05:30,120
So build and run it, enter a three digit number.
74
00:05:30,500 --> 00:05:32,720
So in our example, what did we have?
75
00:05:33,530 --> 00:05:36,040
How we have five three one.
76
00:05:36,980 --> 00:05:43,310
So the total on some of these digits in five three one is nine exactly as we expected.
77
00:05:43,310 --> 00:05:46,080
Five plus three is eight plus one is nine.
78
00:05:46,460 --> 00:05:54,080
Let's use additional example and simply use here, I don't know, two hundred forty seven and the total
79
00:05:54,080 --> 00:05:58,670
sum of digits in two hundred forty seven is thirteen.
80
00:05:58,670 --> 00:06:00,110
Just let's make sure of it.
81
00:06:00,320 --> 00:06:04,310
Two plus four is six, six plus seven is 13.
82
00:06:04,610 --> 00:06:08,210
So it seems to be working properly, correctly.
83
00:06:08,780 --> 00:06:15,860
And I hope that all the steps here, I tried to do my best to make them as practical and understandable
84
00:06:15,860 --> 00:06:17,360
to you guys as possible.
85
00:06:17,780 --> 00:06:21,950
So, yeah, I guess this is it for this video.
86
00:06:21,950 --> 00:06:26,750
Very important to understand the concepts of the concept of unit stands and hundreds.
87
00:06:27,710 --> 00:06:34,160
It will guide us during these chorusing additional exercises in more complicated topics, in more advanced
88
00:06:34,160 --> 00:06:34,610
topics.
89
00:06:35,510 --> 00:06:42,620
But if you will understand the main principle in the main concept of how you should work with them at
90
00:06:42,620 --> 00:06:47,380
this moment, there should be actually no problems later on.
91
00:06:48,080 --> 00:06:50,120
So thank you guys for watching.
92
00:06:50,500 --> 00:06:52,750
If you have any questions, feel free to ask them.
93
00:06:52,940 --> 00:06:59,300
My name is Vlad is Alphatech, and until the next video, until the next exercise.
94
00:06:59,300 --> 00:07:01,390
I wish you a great day.
8821
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.