1
00:00:00,570 --> 00:00:01,290
Welcome back.

2
00:00:01,710 --> 00:00:05,970
In this lecture, we will create a simple calculator.

3
00:00:07,080 --> 00:00:09,120
So let's start.

4
00:00:10,210 --> 00:00:12,490
By creating a new project.

5
00:00:13,370 --> 00:00:17,870
In my car, I will create a folder called.

6
00:00:22,130 --> 00:00:24,160
Project, OK?

7
00:00:25,430 --> 00:00:32,120
First thing we need to make sure that I install we can use the.

8
00:00:33,260 --> 00:00:42,170
Interpretive settings for the project and we can add the package by Sempill GeoEye.

9
00:00:43,610 --> 00:00:45,830
Or we can use.

10
00:00:47,170 --> 00:00:56,320
The command line, I will use the command line at my school by Sempill Jilli to open the command line,

11
00:00:56,320 --> 00:00:58,040
you will open the terminal near.

12
00:00:58,870 --> 00:01:00,640
Now it's installed.

13
00:01:01,300 --> 00:01:01,900
I will.

14
00:01:03,280 --> 00:01:06,820
Right, click on the folders and create.

15
00:01:09,410 --> 00:01:10,240
Fight and fight.

16
00:01:10,830 --> 00:01:11,990
I will call this.

17
00:01:12,980 --> 00:01:19,100
Calculators and let's start by creating Daliyah.

18
00:01:20,080 --> 00:01:25,570
I'll import my Sempill GeoEye as S.G..

19
00:01:28,270 --> 00:01:31,550
We need to create a two columns layout.

20
00:01:31,960 --> 00:01:37,300
Let's open that calculator and we will create something like this.

21
00:01:38,200 --> 00:01:44,230
We will create an input box, then we will create these buttons.

22
00:01:46,540 --> 00:01:49,030
I will create all of this as one column.

23
00:01:50,270 --> 00:01:54,810
All of this and this is as another courtroom, OK?

24
00:01:54,830 --> 00:02:04,040
Of course, we can have multiple options to do this, but this means that I have three buttons in.

25
00:02:06,430 --> 00:02:08,590
And this will be another.

26
00:02:08,830 --> 00:02:18,340
So let's start creating this layout, I'll create code one, which will equal to a list of lists.

27
00:02:18,340 --> 00:02:22,390
I'll create a button this button.

28
00:02:23,310 --> 00:02:24,090
Will be.

29
00:02:25,210 --> 00:02:29,110
Seven, I'll give it size.

30
00:02:30,370 --> 00:02:40,240
Will equal food and two, for example, then let's add, this will be the eighth, I'll give it the

31
00:02:40,240 --> 00:02:41,020
same size.

32
00:02:41,980 --> 00:02:42,940
And finally.

33
00:02:45,780 --> 00:02:49,130
I'll give it a size of four.

34
00:02:49,850 --> 00:02:52,880
And, too, of course, we could have created this.

35
00:02:53,940 --> 00:02:57,450
Is a full loop, and now we have created our.

36
00:02:58,240 --> 00:03:05,860
For this one, two and five and then three and six.

37
00:03:07,050 --> 00:03:13,770
OK, we will need to add another row in here for the zero.

38
00:03:14,790 --> 00:03:17,220
We will put also the division.

39
00:03:19,710 --> 00:03:25,230
So I had a button, I led a division sign and I gave it the same size.

40
00:03:26,260 --> 00:03:31,780
Four and two, then we will add the zero and.

41
00:03:32,780 --> 00:03:40,960
I will just add another button for the moment with the same size, but with no text.

42
00:03:42,060 --> 00:03:48,750
OK, this is our first call, the second column will be.

43
00:03:50,240 --> 00:03:55,820
The operators, we have full rules, so we will have to create.

44
00:03:56,780 --> 00:04:04,760
For Rose again and here, for example, down multiplication, this will be the multiplication and I'll

45
00:04:04,760 --> 00:04:08,060
give it the same size for two.

46
00:04:09,000 --> 00:04:11,220
And I'll give it a key.

47
00:04:12,370 --> 00:04:16,700
This will be a for multiplication.

48
00:04:17,590 --> 00:04:20,260
I'll also create a key.

49
00:04:21,350 --> 00:04:22,100
For this one.

50
00:04:23,250 --> 00:04:24,510
Which will be.

51
00:04:25,690 --> 00:04:27,190
The vision, for example.

52
00:04:28,840 --> 00:04:30,100
Then let's create.

53
00:04:33,670 --> 00:04:39,970
I will create substract subtraction, addition and equal.

54
00:04:40,670 --> 00:04:42,320
This will be some.

55
00:04:43,540 --> 00:04:44,230
Addition.

56
00:04:45,110 --> 00:04:46,340
And E!

57
00:04:48,470 --> 00:04:57,170
For equal, and this should be named according to now, let's create our Lahart, which will equal to.

58
00:04:58,080 --> 00:05:02,730
And improve, but this will have the size of.

59
00:05:03,760 --> 00:05:10,570
Ten and one, for example, and we will give it a key of this play.

60
00:05:11,470 --> 00:05:16,890
OK, and let's create our column layout.

61
00:05:17,620 --> 00:05:19,960
This will be cool.

62
00:05:20,850 --> 00:05:29,010
Column one, and we can add vertical separators and as Gevalt goes, cool, too.

63
00:05:29,850 --> 00:05:30,960
OK, that's it.

64
00:05:31,440 --> 00:05:33,530
We have created our layout.

65
00:05:34,060 --> 00:05:45,660
Now let's create our window, which we to with window calculators as Eitel, and we will give it a layout.

66
00:05:46,320 --> 00:05:58,560
While true events and values will equal to when the dot read, and then we will print land and values

67
00:05:59,220 --> 00:06:10,710
and then we will check if event equals is not win closed because we do not have a cancel button, we

68
00:06:10,710 --> 00:06:12,660
will break out of the loop.

69
00:06:13,410 --> 00:06:18,010
Otherwise we will print event and values for now.

70
00:06:18,720 --> 00:06:21,350
OK, and this is great.

71
00:06:21,990 --> 00:06:24,180
Let's give this shot.

72
00:06:24,330 --> 00:06:31,280
I'll just like to run and it seems we have a mistake.

73
00:06:31,770 --> 00:06:38,110
We have created something wrong in here at the display.

74
00:06:38,580 --> 00:06:41,780
This is not inside l'Est.

75
00:06:42,360 --> 00:06:45,630
Now you have seen how it will handle this.

76
00:06:45,630 --> 00:06:47,310
It will display this here.

77
00:06:47,310 --> 00:06:49,470
Masset, let's run it again.

78
00:06:49,650 --> 00:06:51,530
And our problem is corrected.

79
00:06:51,880 --> 00:06:54,280
Of course, this is very small.

80
00:06:54,900 --> 00:07:04,950
Let's give it another parameters that is found, for example, will equal to none to use the default

81
00:07:04,950 --> 00:07:05,430
font.

82
00:07:05,910 --> 00:07:10,470
But I'll give it size 30 and this will.

83
00:07:11,550 --> 00:07:13,600
Displayed much nicer.

84
00:07:14,190 --> 00:07:16,260
OK, this is very nice.

85
00:07:17,060 --> 00:07:19,420
Of course, when I click on these.

86
00:07:19,890 --> 00:07:21,780
Nothing will happen.

87
00:07:22,410 --> 00:07:26,040
It will just print the event on the command line.

88
00:07:26,490 --> 00:07:28,620
OK, very nice.

89
00:07:29,280 --> 00:07:30,360
Now we have.

90
00:07:31,110 --> 00:07:36,990
To check what he is pren, we have to separate the values from the operations.

91
00:07:37,290 --> 00:07:52,560
So let's check if this is an operation, if event in multiple life or subtract, let's close this and

92
00:07:53,670 --> 00:07:59,540
subtract or add or divide.

93
00:08:00,060 --> 00:08:03,510
These are the four operations that we have.

94
00:08:04,030 --> 00:08:14,100
If the key is one of these, then this means that I will normally when the user.

95
00:08:15,090 --> 00:08:24,990
Click the operation, this mean that you had already entered a number and then you want to apply an

96
00:08:24,990 --> 00:08:33,240
operation in it, so I'll just take whatever's in the display and I'll save it as a number.

97
00:08:33,260 --> 00:08:44,070
So all the values of the whatevers in the display of day, of course, I can check if the value of the

98
00:08:44,070 --> 00:08:46,650
display doesn't contain anything.

99
00:08:46,650 --> 00:08:49,530
I should pop up a message we can check.

100
00:08:49,830 --> 00:08:58,080
If the display doesn't contain a valid number, we can just display for the user to enter a valid number.

101
00:08:58,800 --> 00:09:02,520
But for simplicity, I'll just use it this way.

102
00:09:03,210 --> 00:09:08,040
OK, so I assume now that the user.

103
00:09:08,860 --> 00:09:18,360
Had entered a no let simulator's normally I'll do something like this when I click on the operation,

104
00:09:18,820 --> 00:09:22,360
so there is already a number but.

105
00:09:23,240 --> 00:09:30,950
If I do not have anything, I normally would not click on any cooperative's.

106
00:09:31,870 --> 00:09:34,810
OK, so when they user.

107
00:09:36,800 --> 00:09:45,020
On an operator, I clear a display window, oh, display.

108
00:09:46,050 --> 00:09:50,160
Not a date with an empty string.

109
00:09:51,070 --> 00:09:54,370
And I will assume that operation.

110
00:09:55,340 --> 00:09:56,960
Is the event.

111
00:09:57,610 --> 00:10:07,720
OK, so I will not enter here unless the user has clicked on one of these operations, I will install

112
00:10:07,720 --> 00:10:18,250
the operation in a variable name operation and I will, Stosh, the value of the first number and I

113
00:10:18,250 --> 00:10:19,840
will update the display.

114
00:10:20,410 --> 00:10:23,530
OK, now let's create.

115
00:10:24,350 --> 00:10:33,350
The no event, OK, now let's handle how a number will be constructed, I will create a variable called

116
00:10:33,860 --> 00:10:42,770
NUM, which will equal to a list of range from zero to 10.

117
00:10:43,280 --> 00:10:47,330
This will have the numbers from zero to.

118
00:10:51,230 --> 00:11:02,120
We will have to convert them into string's because whatever return from any event is saying, let's

119
00:11:02,120 --> 00:11:02,740
check this.

120
00:11:03,440 --> 00:11:11,240
We need to treat them as a string because when I get back nine, eight, seven, they should be treated

121
00:11:11,240 --> 00:11:15,290
as a string because I am entering nine hundred and eighty seven.

122
00:11:15,800 --> 00:11:26,960
OK, I'm not adding nine to eighty seven, so I will convert this to string by using this tier of X

123
00:11:27,740 --> 00:11:30,750
for x o k.

124
00:11:30,770 --> 00:11:35,990
This will convert to string and let's check if.

125
00:11:36,830 --> 00:11:50,570
The event is in these numbers, OK, as if a one in none current event, and I will just commend this,

126
00:11:51,050 --> 00:11:52,300
let you.

127
00:11:52,700 --> 00:11:55,520
OK, so it's entering already.

128
00:11:56,330 --> 00:11:56,910
Very nice.

129
00:11:57,290 --> 00:12:03,890
So what we can do now is I will just I need to construct the number.

130
00:12:04,100 --> 00:12:05,660
I would name these two numbers.

131
00:12:06,120 --> 00:12:10,520
This also two numbers and I will create something called number.

132
00:12:10,940 --> 00:12:13,640
I will assign it an empty string.

133
00:12:14,120 --> 00:12:20,990
And I here I will say none plus equal that.

134
00:12:21,290 --> 00:12:28,190
Then we will update the display with the value of no.

135
00:12:28,820 --> 00:12:29,600
Now let's try.

136
00:12:29,690 --> 00:12:30,260
Very nice.

137
00:12:30,500 --> 00:12:30,900
OK.

138
00:12:31,340 --> 00:12:37,970
Of course we can make this as complex as we want, but there is no zero on the left.

139
00:12:38,270 --> 00:12:46,010
Any number should not start with Dero, so we should check if the number is equal to zero at the beginning.

140
00:12:46,010 --> 00:12:47,630
We will skip this one.

141
00:12:47,980 --> 00:13:00,230
OK, so I will check if lan o num equals zero does mean that this is the first time an event not equal

142
00:13:00,590 --> 00:13:02,770
zero zero as a string.

143
00:13:03,170 --> 00:13:13,340
This means that this is the first number I enter in the Chaltain health lenn of none greater than zero.

144
00:13:13,610 --> 00:13:17,230
Then we will exactly do the same thing.

145
00:13:17,510 --> 00:13:26,480
So if I click on any number between one and nine at the beginning, it will story and it will execute

146
00:13:26,480 --> 00:13:26,720
this.

147
00:13:26,990 --> 00:13:33,920
Otherwise, if this is the first time and the number that digit that I am entering is zero, it will

148
00:13:33,920 --> 00:13:34,550
not update.

149
00:13:34,640 --> 00:13:44,150
Let's check this when I click on this, because Delane of the number is zero, but if I click anything

150
00:13:44,150 --> 00:13:44,840
else, it will.

151
00:13:45,320 --> 00:13:47,780
OK, I'll close this now.

152
00:13:47,780 --> 00:13:52,280
We have created our numbers and we have a support our operation.

153
00:13:52,580 --> 00:13:59,180
The last thing is we need to check if what's entered is the equal or greater.

154
00:13:59,510 --> 00:14:05,840
If the event equals equal, this means that we have pressed the equal button.

155
00:14:06,080 --> 00:14:13,920
We normally will press equal button after we have entered the first number and click on operation and

156
00:14:14,440 --> 00:14:15,740
the second number.

157
00:14:15,890 --> 00:14:24,800
OK, so at this time I will create num one equal float of I will convert to float.

158
00:14:24,950 --> 00:14:27,830
I will create another variable called num to.

159
00:14:28,190 --> 00:14:33,400
This will be the value that is entered on the display.

160
00:14:33,770 --> 00:14:36,350
Let's check the calculators again.

161
00:14:36,620 --> 00:14:44,440
I'll enter for example this number plus three, two, one example and then I'll press equal.

162
00:14:44,450 --> 00:14:47,930
So the first number is put in number one.

163
00:14:48,290 --> 00:14:54,920
The second number when I click the equal time is presented on the display.

164
00:14:55,430 --> 00:15:04,130
So the operation will happen any so I will convert values of this play.

165
00:15:04,310 --> 00:15:06,500
I will convert it to float.

166
00:15:06,810 --> 00:15:11,690
OK, and then let's check what type of operation.

167
00:15:11,690 --> 00:15:23,330
If Operation equals two act for example, then a result for example will equal to num one plus num two.

168
00:15:23,540 --> 00:15:37,670
OK, else if operation equals subtract result will equal to num one minus two ls if operation equals

169
00:15:38,060 --> 00:15:41,870
multiply result with equal to number one.

170
00:15:42,110 --> 00:15:44,650
You get the idea right, you get the idea.

171
00:15:44,990 --> 00:15:54,290
And finally, if operation equals to division, result will equal to number one.

172
00:15:54,590 --> 00:15:56,510
Divided number two.

173
00:15:56,780 --> 00:16:02,960
OK, now we have calculated everything we should update our display.

174
00:16:03,140 --> 00:16:10,160
So window of display, not a date and I'll convert.

175
00:16:10,760 --> 00:16:12,890
That is to integrate.

176
00:16:13,340 --> 00:16:14,330
Of course we can.

177
00:16:14,630 --> 00:16:18,020
We could have made lots of conditions.

178
00:16:18,200 --> 00:16:18,560
Lots.

179
00:16:18,560 --> 00:16:26,420
So let's check this when I click on plus I have like calibration.

180
00:16:27,050 --> 00:16:29,090
Let's check this.

181
00:16:29,490 --> 00:16:30,380
Oh, OK.

182
00:16:30,560 --> 00:16:33,290
I'll play that, for example.

183
00:16:33,290 --> 00:16:34,580
And six.

184
00:16:34,870 --> 00:16:36,300
Oh, uh, OK.

185
00:16:36,460 --> 00:16:43,960
When we click on the operation, we said we should reset the value of none to an empty string.

186
00:16:44,260 --> 00:16:54,460
So we have already saved this value in Namwon, so we will not have to worry about it.

187
00:16:54,910 --> 00:16:59,130
I'll just Sanam will equal to an empty string.

188
00:16:59,470 --> 00:17:05,560
Let run plus six, five, four equals.

189
00:17:06,200 --> 00:17:07,970
Hey, I think this is correct.

190
00:17:08,470 --> 00:17:15,790
And again, after equal, we should also do the same thing we can put in.

191
00:17:16,150 --> 00:17:19,430
None will equal to an empty string.

192
00:17:19,840 --> 00:17:22,620
Let's do a simple math.

193
00:17:22,780 --> 00:17:26,930
Five plus six to 11.

194
00:17:26,950 --> 00:17:28,570
This is nice.

195
00:17:28,750 --> 00:17:32,980
Four minus three equals one.

196
00:17:33,430 --> 00:17:38,050
Nine times two equals within.

197
00:17:38,050 --> 00:17:38,890
This is nice.

198
00:17:39,250 --> 00:17:44,830
Eight divided four equals to this is.

199
00:17:45,710 --> 00:17:46,400
Very nice.

200
00:17:46,550 --> 00:17:53,640
Of course, we could have complicated this a bit more, but this is not the school.

201
00:17:53,960 --> 00:17:59,570
The school's OK, so this will conclude our project.

202
00:17:59,990 --> 00:18:03,270
Thank you for watching and join me in the next lecture.
