1
00:00:00,150 --> 00:00:04,560
in this course I'm gonna teach you everything you need to know to get started programming in

2
00:00:04,590 --> 00:00:05,310
python.

3
00:00:05,700 --> 00:00:09,270
Python is one of the most popular programming languages out there,

4
00:00:09,450 --> 00:00:13,200
and it's by far one of the most sought after for jobs

5
00:00:13,410 --> 00:00:14,910
and so if you're trying to get a job

6
00:00:14,940 --> 00:00:16,170
or you're trying to you know,

7
00:00:16,200 --> 00:00:17,400
automate your life

8
00:00:17,520 --> 00:00:20,580
or you try to write awesome scripts to do a bunch of different things than

9
00:00:20,610 --> 00:00:21,840
python's for you

10
00:00:21,990 --> 00:00:22,410
honestly

11
00:00:22,440 --> 00:00:27,600
more and more developers every day are moving their projects over to python because it's such a powerful

12
00:00:27,780 --> 00:00:28,350
and the surgeon

13
00:00:28,380 --> 00:00:29,640
easy to use language,

14
00:00:29,910 --> 00:00:33,330
a lot of programming languages out there just aren't very beginner friendly there's

15
00:00:33,690 --> 00:00:38,490
a lot of syntax there's a lot of like little things that if you get wrong the program will yell at you.

16
00:00:38,700 --> 00:00:39,930
python is the complete

17
00:00:39,960 --> 00:00:40,890
opposite of that.

18
00:00:41,010 --> 00:00:45,660
you basically just type out what you want to do in python does it it's that simple there's not

19
00:00:45,870 --> 00:00:50,460
a whole lot of syntax to learn the learning curve is literally zero you jump in,

20
00:00:50,610 --> 00:00:53,100
you can start writing your first program in seconds.

21
00:00:53,370 --> 00:00:54,180
in this course

22
00:00:54,210 --> 00:00:55,260
I'm gonna teach you guys.

23
00:00:55,470 --> 00:00:57,840
everything you need to know to get started in python.

24
00:00:58,020 --> 00:00:59,070
I designed this course

25
00:00:59,100 --> 00:01:00,840
especially for python,

26
00:01:00,960 --> 00:01:03,810
and each lesson has been specially designed with examples

27
00:01:03,840 --> 00:01:05,130
that will help you along the way.

28
00:01:05,190 --> 00:01:07,800
with so many people starting to learn python the question isn't,

29
00:01:08,010 --> 00:01:11,130
why should you learn pipe on the question is why shouldn't you ?

30
00:01:11,460 --> 00:01:17,910
and I think for a lot of people the reason they might not want to learn python is because they're intimidated or they're afraid that it's going to be too hard.

31
00:01:18,240 --> 00:01:24,810
trust me I am going to hold your hand through this entire course we're going to talk about all the core concepts in python we're going to look at

32
00:01:25,170 --> 00:01:26,490
everything you need to know

33
00:01:26,580 --> 00:01:34,110
to start programming in python and start being confidence are writing scripts and start writing programs that are awesome in doing cool things in your life.

34
00:01:34,320 --> 00:01:34,800
anyway

35
00:01:34,890 --> 00:01:37,140
I'm super pumped to be teaching you guys python.

36
00:01:37,200 --> 00:01:38,850
I can't wait to get started in this course

37
00:01:38,880 --> 00:01:44,100
and I hope you guys stick around and fall along with the course and learn this amazing programming language

38
00:01:48,150 --> 00:01:52,320
in this tutorial dominates three guys how to install python onto your computer.

39
00:01:52,650 --> 00:01:56,220
and we're also going to install a text editor that we can use to write

40
00:01:56,250 --> 00:01:57,720
our python programs

41
00:01:57,780 --> 00:01:58,110
in.

42
00:01:58,590 --> 00:02:01,560
so the first order of business is to actually install

43
00:02:01,590 --> 00:02:03,360
python on your computer.

44
00:02:03,660 --> 00:02:06,120
so we want to do is head over to your web browser

45
00:02:06,630 --> 00:02:07,140
and

46
00:02:07,170 --> 00:02:09,330
you want to go over here to this page it's just

47
00:02:09,690 --> 00:02:12,180
www dot python dot org

48
00:02:12,210 --> 00:02:13,260
forward slash

49
00:02:13,290 --> 00:02:14,130
downloads

50
00:02:14,430 --> 00:02:14,940
and on this

51
00:02:14,970 --> 00:02:15,780
page there's

52
00:02:15,810 --> 00:02:16,350
going to be

53
00:02:16,380 --> 00:02:17,700
two buttons down here

54
00:02:18,030 --> 00:02:21,540
and this is going to say download python three point six point three.

55
00:02:21,990 --> 00:02:22,590
and at least

56
00:02:22,620 --> 00:02:26,850
the version that I have right now or download python two point seven point one four.

57
00:02:27,420 --> 00:02:31,770
so here's the thing about python there's actually two major versions of python

58
00:02:31,800 --> 00:02:32,940
that are in use

59
00:02:32,970 --> 00:02:33,570
currently

60
00:02:33,930 --> 00:02:34,440
there is

61
00:02:34,470 --> 00:02:35,640
python two

62
00:02:35,700 --> 00:02:38,130
and there's python theories you can see over here,

63
00:02:38,340 --> 00:02:40,920
this is like two point seven point one four

64
00:02:41,610 --> 00:02:43,890
basically any python two

65
00:02:43,980 --> 00:02:46,170
version we would just refer to as like python two

66
00:02:46,440 --> 00:02:47,670
and here's like the latest

67
00:02:47,700 --> 00:02:49,200
python three version.

68
00:02:49,380 --> 00:02:55,230
and so there's these two versions that you can download and the first thing we have to decide on which version do we want to download.

69
00:02:55,500 --> 00:02:56,760
and here's the basic difference

70
00:02:56,820 --> 00:02:57,540
python

71
00:02:57,570 --> 00:02:58,230
two

72
00:02:58,500 --> 00:03:01,920
is a legacy version of python which basically means that

73
00:03:02,160 --> 00:03:02,760
it's like an

74
00:03:02,790 --> 00:03:07,170
old version and it's not being like actively maintained or supported

75
00:03:07,350 --> 00:03:09,570
like officially by python anymore.

76
00:03:09,870 --> 00:03:10,380
python

77
00:03:10,410 --> 00:03:16,830
three is like the future of python it's like the newest version it's the one that's getting actively maintained and supported.

78
00:03:17,130 --> 00:03:19,830
so there's pros and cons to picking either won

79
00:03:20,490 --> 00:03:22,770
a lot of people say like python too

80
00:03:22,830 --> 00:03:25,440
has been around longer and so there's more like

81
00:03:25,590 --> 00:03:30,270
libraries there's basically just more python code written in python two

82
00:03:30,600 --> 00:03:35,400
so therefore like there's a few more things that you can do in pipe onto then you can do in python three

83
00:03:35,730 --> 00:03:36,630
but then again

84
00:03:36,780 --> 00:03:38,880
python two is not supported and you know,

85
00:03:38,970 --> 00:03:40,350
five or ten years from now

86
00:03:40,380 --> 00:03:42,120
probably no one's going to be using it.

87
00:03:42,810 --> 00:03:47,100
python three it like a site is like the future of python it's the newest version it's the one that

88
00:03:47,130 --> 00:03:49,800
you know it's sort of being maintained going forward.

89
00:03:50,280 --> 00:03:53,460
so for the purposes of this tutorial I'm going to be teaching you guys

90
00:03:53,490 --> 00:03:54,240
python

91
00:03:54,270 --> 00:03:55,020
three

92
00:03:55,200 --> 00:03:57,120
so we're going to want to download python

93
00:03:57,150 --> 00:03:57,600
three

94
00:03:57,840 --> 00:03:58,860
now here's vaguely

95
00:03:59,040 --> 00:04:03,450
if you learn python three or you learn python to the differences aren't very big.

96
00:04:03,720 --> 00:04:07,050
there are a few differences in like some syntax and just so

97
00:04:07,080 --> 00:04:08,700
you know little things here and there,

98
00:04:08,760 --> 00:04:11,700
but if you learn python three you'll be able to jump right in and

99
00:04:11,730 --> 00:04:14,610
code in python two as well don't let anyone

100
00:04:14,940 --> 00:04:15,630
tell you that

101
00:04:15,720 --> 00:04:17,040
you have to learn one of the other.

102
00:04:17,100 --> 00:04:21,840
we're going to learn python three just because it's I think probably the best for a beginner to learn.

103
00:04:22,050 --> 00:04:26,159
and so that's the one that we want to download so I'm just going to click download python three

104
00:04:26,489 --> 00:04:27,749
and we're gonna go ahead and download

105
00:04:27,779 --> 00:04:28,649
this version.

106
00:04:29,009 --> 00:04:33,089
and when that's done downloading I'm going to head down to my downloads folder

107
00:04:33,989 --> 00:04:35,969
and you'll see here we just have this file

108
00:04:36,989 --> 00:04:37,679
doubleclick,

109
00:04:37,949 --> 00:04:41,609
and we get this like python installer so I'm going to click through here,

110
00:04:42,029 --> 00:04:45,359
and we'll be able to install python three on our computer

111
00:04:45,509 --> 00:04:51,449
right when that's done and stalling we can just close out of this and we should begin to get us now we have python three

112
00:04:51,719 --> 00:04:53,159
installed on our computer.

113
00:04:53,549 --> 00:04:54,479
the next step

114
00:04:54,509 --> 00:04:56,399
is we need to choose a text

115
00:04:56,429 --> 00:04:57,239
editor so

116
00:04:57,899 --> 00:05:04,529
we're going to be writing a bunch of code so we're going to need some you know environment of some program that we can write all that code in.

117
00:05:04,829 --> 00:05:09,959
and really you can write python in any text editor you could write it in like a note pad or tax at it,

118
00:05:10,199 --> 00:05:11,099
it doesn't really matter

119
00:05:11,339 --> 00:05:13,019
but there are special

120
00:05:13,049 --> 00:05:14,699
text editors that are designed

121
00:05:14,729 --> 00:05:16,979
just for writing python code.

122
00:05:17,249 --> 00:05:18,209
and these are called

123
00:05:18,269 --> 00:05:20,129
id ease and not stands for

124
00:05:20,159 --> 00:05:22,019
integrated development environment.

125
00:05:22,379 --> 00:05:27,269
it's basically just a special environment where we can you know ron and execute our python code.

126
00:05:27,479 --> 00:05:30,569
and it'll you know basically like tell us how we're doing so were

127
00:05:30,629 --> 00:05:32,879
the only if we write something that's wrong or we

128
00:05:32,909 --> 00:05:34,109
have errors it'll kind of

129
00:05:34,529 --> 00:05:37,259
point us in the right direction of what we need to do to fix that stuff,

130
00:05:37,649 --> 00:05:39,779
so in this course we're going to be using an idea

131
00:05:39,809 --> 00:05:40,229
and

132
00:05:40,259 --> 00:05:41,219
one of my favorites

133
00:05:41,249 --> 00:05:44,879
and one of the most popular ity ease for python is called pi charm.

134
00:05:45,239 --> 00:05:46,889
so I'm over here on this website.

135
00:05:46,949 --> 00:05:47,489
it's called

136
00:05:47,519 --> 00:05:48,599
jet brains

137
00:05:48,629 --> 00:05:49,559
dotcom

138
00:05:49,589 --> 00:05:50,519
forward slash

139
00:05:50,549 --> 00:05:51,329
pi charm.

140
00:05:51,659 --> 00:05:54,569
and this is the idea that we're gonna be using in this course

141
00:05:54,599 --> 00:05:57,029
so I'm just gonna come over here and click this big download

142
00:05:57,059 --> 00:05:57,809
now button

143
00:05:58,319 --> 00:05:59,668
and we'll go ahead and

144
00:05:59,698 --> 00:06:00,629
download this

145
00:06:00,659 --> 00:06:01,979
pie charm program

146
00:06:02,309 --> 00:06:06,268
right so I'm getting this page are here you can see there's two versions of pi charm

147
00:06:06,478 --> 00:06:09,958
one as a professional version and that one's like paid they have to pay for it.

148
00:06:10,228 --> 00:06:14,878
but then there's this community version down here and that's free and open source so I'm going to download this one

149
00:06:15,268 --> 00:06:18,688
and this should have everything we need to get started using python

150
00:06:19,258 --> 00:06:21,658
right when that finishes downloading I'm just going to

151
00:06:21,688 --> 00:06:23,458
pull that up in my downloads folder

152
00:06:23,938 --> 00:06:24,538
and

153
00:06:24,598 --> 00:06:25,738
again we can just sort of

154
00:06:25,768 --> 00:06:26,818
run this guy

155
00:06:26,938 --> 00:06:30,778
and I'm on a mac so I'm going to have to drag it over to my applications folder.

156
00:06:31,258 --> 00:06:33,058
all right so now have pi charm

157
00:06:33,088 --> 00:06:34,498
and we have python

158
00:06:34,528 --> 00:06:36,328
three installed on your computer.

159
00:06:36,748 --> 00:06:39,118
so we're ready to start programming in

160
00:06:39,148 --> 00:06:39,868
python.

161
00:06:43,768 --> 00:06:46,108
in this tutorial we're going to create our first

162
00:06:46,138 --> 00:06:47,248
python program.

163
00:06:47,518 --> 00:06:48,988
and we're going to be able to run it and

164
00:06:49,048 --> 00:06:50,848
see how everything works.

165
00:06:51,088 --> 00:06:52,708
the first thing I want to do is open up

166
00:06:52,738 --> 00:06:54,808
pi charm so pi charm was the

167
00:06:54,838 --> 00:06:55,948
idea he the

168
00:06:56,008 --> 00:06:57,658
integrated development environment

169
00:06:57,928 --> 00:07:00,388
that we downloaded in the last tutorial so

170
00:07:00,658 --> 00:07:02,698
I'm just going to go out and search for it on my computer

171
00:07:03,508 --> 00:07:04,708
and I can just open it up

172
00:07:04,768 --> 00:07:07,918
and we first opened up high charm we should basically just get a window

173
00:07:07,948 --> 00:07:10,588
prompting us to create a project.

174
00:07:10,858 --> 00:07:12,058
so you can see that down here.

175
00:07:12,328 --> 00:07:15,777
actually the first thing I want to do though is come over here to configure

176
00:07:16,287 --> 00:07:17,247
and I'm just going to

177
00:07:17,277 --> 00:07:18,627
click on preferences.

178
00:07:19,077 --> 00:07:20,757
and I actually want to

179
00:07:20,787 --> 00:07:22,347
change the appearance

180
00:07:22,377 --> 00:07:22,887
so

181
00:07:23,337 --> 00:07:24,627
I'm gonna go ahead and

182
00:07:25,167 --> 00:07:28,707
give this a theme so I just went over here to appearance and behavior appearance

183
00:07:29,067 --> 00:07:30,927
and I'm gonna change the theme to

184
00:07:31,047 --> 00:07:31,767
darker color

185
00:07:31,917 --> 00:07:33,807
because I think it's a little bit easier to

186
00:07:33,897 --> 00:07:35,037
use and look at,

187
00:07:35,247 --> 00:07:36,957
but you don't have to do that if you don't want you

188
00:07:37,437 --> 00:07:38,037
so

189
00:07:38,067 --> 00:07:38,727
down here

190
00:07:38,757 --> 00:07:39,507
I'm just going to click

191
00:07:39,537 --> 00:07:40,917
create new projects

192
00:07:41,307 --> 00:07:41,967
and it's going to

193
00:07:41,997 --> 00:07:45,567
give us this little window right here so I can just name my project.

194
00:07:45,897 --> 00:07:47,157
and I'm just going to name this

195
00:07:47,217 --> 00:07:47,967
graph.

196
00:07:48,597 --> 00:07:51,777
and then there's other option down here where it says interpreter.

197
00:07:52,167 --> 00:07:52,677
now

198
00:07:53,487 --> 00:07:54,657
what we wanna select

199
00:07:54,687 --> 00:07:55,287
is

200
00:07:55,377 --> 00:07:57,087
python version three

201
00:07:57,117 --> 00:08:00,837
so if I click down here you'll notice that there's a couple different options.

202
00:08:01,077 --> 00:08:02,907
so I'm on a mac computer

203
00:08:02,937 --> 00:08:03,387
and

204
00:08:03,417 --> 00:08:05,517
by default mac has

205
00:08:05,577 --> 00:08:06,237
python

206
00:08:06,267 --> 00:08:08,127
version two installed on it.

207
00:08:08,427 --> 00:08:11,277
if you're on a windows machine I'm not sure if it does but

208
00:08:11,907 --> 00:08:16,437
in this tutorial we're going to be using python three so you wanna make sure that you have python

209
00:08:16,467 --> 00:08:18,807
three selected as the interpreter,

210
00:08:19,077 --> 00:08:19,587
otherwise

211
00:08:19,737 --> 00:08:19,977
you

212
00:08:20,007 --> 00:08:23,007
might not be able to fully follow along with what we're doing in this video.

213
00:08:23,307 --> 00:08:25,377
so now it's going to come down here and click

214
00:08:25,407 --> 00:08:26,007
create.

215
00:08:26,277 --> 00:08:28,737
and this is going to go ahead and create our projects

216
00:08:28,767 --> 00:08:29,517
for us

217
00:08:29,607 --> 00:08:30,807
right so now we have

218
00:08:30,837 --> 00:08:31,377
our

219
00:08:31,407 --> 00:08:32,307
python project

220
00:08:32,337 --> 00:08:32,967
up and running,

221
00:08:33,327 --> 00:08:36,177
and I'm sure you guys how we can create our first

222
00:08:36,297 --> 00:08:37,617
python program,

223
00:08:37,917 --> 00:08:42,297
so over here in this draft folder and this is just that project that we created.

224
00:08:42,746 --> 00:08:43,736
I'm just going to right click

225
00:08:43,767 --> 00:08:44,937
and I'm saying new

226
00:08:45,627 --> 00:08:46,857
and I'm going to come down and click

227
00:08:46,887 --> 00:08:50,487
python file so we want to create a new python file this will be our first

228
00:08:50,517 --> 00:08:51,567
python program.

229
00:08:52,137 --> 00:08:52,467
and

230
00:08:52,497 --> 00:08:53,787
I can just give this a name,

231
00:08:53,847 --> 00:08:55,197
so why don't we just call this

232
00:08:55,287 --> 00:08:55,617
app

233
00:08:55,737 --> 00:08:56,817
and it's going to click ok

234
00:08:56,937 --> 00:08:59,097
all right so now we have our first

235
00:08:59,127 --> 00:08:59,937
python file

236
00:08:59,967 --> 00:09:00,507
open

237
00:09:01,017 --> 00:09:04,407
and we can just start typing in some python so I want to show you guys.

238
00:09:04,617 --> 00:09:06,837
does a very basic python program.

239
00:09:07,047 --> 00:09:11,698
and this is just going to be a hello world programs so we're just gonna print something out onto the screen.

240
00:09:11,998 --> 00:09:12,538
so when I say

241
00:09:12,598 --> 00:09:15,928
what I want to do is I want to type out p r iyer anti prince

242
00:09:16,348 --> 00:09:17,008
and wanted to have an

243
00:09:17,038 --> 00:09:17,938
open and closed

244
00:09:17,968 --> 00:09:18,808
parentheses

245
00:09:19,048 --> 00:09:19,348
now

246
00:09:19,378 --> 00:09:21,838
inside of those parentheses we can make some

247
00:09:21,868 --> 00:09:22,798
quotation marks

248
00:09:23,008 --> 00:09:25,408
and inside of the quotation marks I'm just going to tape out

249
00:09:25,468 --> 00:09:26,218
hello

250
00:09:26,278 --> 00:09:26,818
world.

251
00:09:27,148 --> 00:09:29,968
so this is like a very basic python program.

252
00:09:30,178 --> 00:09:31,438
and what this is gonna do is

253
00:09:31,468 --> 00:09:33,718
it's just going to print out hello world

254
00:09:33,748 --> 00:09:34,828
onto the screen.

255
00:09:35,278 --> 00:09:36,568
and so now what I can do

256
00:09:36,658 --> 00:09:41,068
is I can actually run this file and we're actually getting a little arrow here it wants us to create a new line

257
00:09:41,368 --> 00:09:42,448
at the end of the file.

258
00:09:42,988 --> 00:09:47,518
and so now in order to run our python program I'm just going to come up here to the top

259
00:09:47,908 --> 00:09:49,348
and I'm cinematic run

260
00:09:49,468 --> 00:09:51,448
and we'll click this run button right here

261
00:09:51,868 --> 00:09:52,948
and I will see what happens

262
00:09:52,979 --> 00:09:53,729
so it's

263
00:09:53,789 --> 00:09:56,249
asking me what I want to run I can just click add up

264
00:09:56,939 --> 00:09:57,359
and

265
00:09:57,389 --> 00:10:01,679
down here at the bottom you'll notice that we have this text that just got printed out

266
00:10:01,709 --> 00:10:02,639
hello world,

267
00:10:02,999 --> 00:10:03,509
so

268
00:10:03,569 --> 00:10:04,349
whatever I

269
00:10:04,409 --> 00:10:04,919
print

270
00:10:05,159 --> 00:10:08,219
or whatever I put inside of this print statement is going to get printed out

271
00:10:08,249 --> 00:10:10,079
down below in the council so

272
00:10:10,319 --> 00:10:13,019
as long as you're getting that print statements work then you

273
00:10:13,109 --> 00:10:15,359
actually written your first python program.

274
00:10:15,659 --> 00:10:16,499
and as we go through it

275
00:10:16,529 --> 00:10:18,059
forward in the course were can be writing

276
00:10:18,089 --> 00:10:20,159
all sorts of awesome python programs.

277
00:10:20,219 --> 00:10:21,059
and we're going to do an

278
00:10:21,089 --> 00:10:22,379
all sorts of cool stuff

279
00:10:26,129 --> 00:10:33,299
in this tutorial I wanna talk to you about writing a basic python programs so we're going to write it as a very simple python program.

280
00:10:33,449 --> 00:10:36,929
we're going to look at how we can go ahead and write up programs we're going to talk about

281
00:10:37,079 --> 00:10:40,229
how our programs are getting executed by python

282
00:10:40,529 --> 00:10:44,099
and we're also going to draw out a little shape onto the screen so

283
00:10:44,339 --> 00:10:46,109
this is going to be pretty cool I'm excited to

284
00:10:46,139 --> 00:10:47,519
talk you guys about just the

285
00:10:47,549 --> 00:10:49,200
bare basics of python,

286
00:10:49,440 --> 00:10:51,720
and really just sort of give you an introduction so

287
00:10:51,810 --> 00:10:52,470
over here

288
00:10:52,650 --> 00:10:53,790
we have our

289
00:10:53,820 --> 00:10:55,320
basic text editor and so

290
00:10:55,680 --> 00:10:56,880
any of the

291
00:10:56,940 --> 00:10:59,790
python code that I write inside of this file

292
00:10:59,970 --> 00:11:02,910
is actually going to get executed by a python so

293
00:11:03,120 --> 00:11:04,440
this python file

294
00:11:04,470 --> 00:11:05,430
has a bunch of

295
00:11:05,460 --> 00:11:06,960
python code inside of it.

296
00:11:07,410 --> 00:11:09,600
and basically what we're doing when we're

297
00:11:09,630 --> 00:11:13,770
programming in python is we're just giving the computer a set of instructions.

298
00:11:14,070 --> 00:11:18,150
right that's really what programming is it's just like we're specifying a set of instructions

299
00:11:18,390 --> 00:11:22,470
and the computer is going to go off and execute those instructions that we give it.

300
00:11:22,980 --> 00:11:23,460
and so

301
00:11:23,490 --> 00:11:27,030
the more complex the instructions we give to the computer the more complex

302
00:11:27,060 --> 00:11:27,900
the tasks

303
00:11:27,930 --> 00:11:28,890
the computer can

304
00:11:28,950 --> 00:11:29,610
carry up.

305
00:11:30,090 --> 00:11:34,620
so I'll show you guys how we can use some python instructions or some python code

306
00:11:34,890 --> 00:11:37,710
in order to draw out a shape onto the screen so

307
00:11:37,950 --> 00:11:39,090
I'm actually going to draw out

308
00:11:39,120 --> 00:11:40,230
a little triangle.

309
00:11:40,650 --> 00:11:41,490
so over here,

310
00:11:41,550 --> 00:11:43,950
we can actually print something out onto the

311
00:11:43,980 --> 00:11:48,060
screen and python using something called a print statement so I can just type out

312
00:11:48,090 --> 00:11:48,540
print.

313
00:11:48,960 --> 00:11:50,970
and inside of these parentheses.

314
00:11:51,390 --> 00:11:52,260
I can just type

315
00:11:52,410 --> 00:11:53,700
some quotation marks

316
00:11:53,730 --> 00:11:54,990
and inside the quotation marks

317
00:11:55,020 --> 00:11:55,410
we can

318
00:11:55,440 --> 00:11:57,480
put whatever we want to print out onto the screen.

319
00:11:57,990 --> 00:11:58,890
so I'm gonna

320
00:11:58,980 --> 00:12:00,631
copy this and I'm actually going to make

321
00:12:00,661 --> 00:12:02,761
a few of these little prince statements

322
00:12:02,971 --> 00:12:04,441
and we're going actually draw a sheep.

323
00:12:04,801 --> 00:12:05,371
so

324
00:12:05,431 --> 00:12:06,391
we're gonna draw like

325
00:12:06,421 --> 00:12:07,921
a triangle type shape

326
00:12:07,951 --> 00:12:10,201
so down here it's gonna draw a forward slash

327
00:12:10,531 --> 00:12:13,951
and then up here I'll make a space and we'll do another foreign sash

328
00:12:14,371 --> 00:12:14,911
here will make

329
00:12:14,941 --> 00:12:16,051
two spaces

330
00:12:16,411 --> 00:12:17,791
with united forward slash.

331
00:12:17,851 --> 00:12:18,691
and over here

332
00:12:18,751 --> 00:12:20,731
we can make three spaces and afford sash.

333
00:12:21,301 --> 00:12:24,721
and now I'm going to draw like a vertical bar is going all the way down.

334
00:12:27,391 --> 00:12:29,701
and actually we can do some underscores here as well.

335
00:12:29,791 --> 00:12:30,511
I think high school

336
00:12:32,011 --> 00:12:35,191
right so now we have our triangle looking shave and you can see

337
00:12:35,461 --> 00:12:37,381
it looks kind of like a right triangle

338
00:12:37,501 --> 00:12:38,911
so I can save my file.

339
00:12:39,211 --> 00:12:41,971
and I can either come up here to run and

340
00:12:42,031 --> 00:12:43,231
click run app

341
00:12:43,531 --> 00:12:47,281
or of using pie charm you can also just come over here and click this play button

342
00:12:47,881 --> 00:12:51,451
and when I click the play button I want you to notice what happens down here

343
00:12:51,751 --> 00:12:52,231
so

344
00:12:52,291 --> 00:12:54,481
down here we have this little window and

345
00:12:54,511 --> 00:12:56,101
this is called the consul

346
00:12:56,611 --> 00:13:00,182
and it basically the council is a place where python is going to

347
00:13:00,242 --> 00:13:02,042
output some information so

348
00:13:02,341 --> 00:13:05,612
when we use this print statement were basically telling python late

349
00:13:05,822 --> 00:13:08,012
hey can you print something out onto the consul.

350
00:13:08,282 --> 00:13:08,612
so

351
00:13:08,642 --> 00:13:12,722
there's a lot of situations where we're gonna wanna see what's going on in our code.

352
00:13:13,052 --> 00:13:14,852
and we can use that print statement and

353
00:13:14,912 --> 00:13:16,562
print things out to the council.

354
00:13:16,802 --> 00:13:20,582
and we can basically like have a little window into what our programs doing

355
00:13:20,972 --> 00:13:24,512
in our case we're just going to be printing out this triangle onto the consul.

356
00:13:24,962 --> 00:13:27,242
so I'm gonna come over here and click this play button

357
00:13:27,722 --> 00:13:28,742
and you'll see down here

358
00:13:28,772 --> 00:13:30,302
we're actually printing out that

359
00:13:30,332 --> 00:13:30,932
triangle

360
00:13:31,172 --> 00:13:34,172
so mission accomplished we were able to print out our shape.

361
00:13:34,502 --> 00:13:37,592
so I can really draw any shape I want it as long as I was

362
00:13:37,622 --> 00:13:38,252
able to

363
00:13:38,282 --> 00:13:39,092
specify

364
00:13:39,122 --> 00:13:40,622
inside of these print statements.

365
00:13:41,162 --> 00:13:41,552
so

366
00:13:41,583 --> 00:13:44,883
essentially what python's doing when I click that play button

367
00:13:45,062 --> 00:13:49,623
is it's going into this file and it's looking at all of these instructions in order.

368
00:13:49,833 --> 00:13:52,623
so the first thing it does is it goes to this instruction and it says

369
00:13:52,653 --> 00:13:53,073
ok,

370
00:13:53,253 --> 00:13:57,903
they want me to draw out these like little forward slash in this vertical bar onto the strain,

371
00:13:58,203 --> 00:14:01,083
once it does that it goes down to this instruction it says

372
00:14:01,113 --> 00:14:01,413
ok

373
00:14:01,443 --> 00:14:02,883
they want me to print something on again

374
00:14:03,183 --> 00:14:05,613
when it prints dot out it goes down to this instruction

375
00:14:05,643 --> 00:14:06,273
etc

376
00:14:06,723 --> 00:14:07,203
so

377
00:14:07,233 --> 00:14:11,223
python is actually going to execute the lines of code that we write

378
00:14:11,523 --> 00:14:12,303
in order.

379
00:14:12,513 --> 00:14:12,933
so

380
00:14:12,963 --> 00:14:14,913
the order in which I write the instructions

381
00:14:14,943 --> 00:14:16,083
matters a lot.

382
00:14:16,173 --> 00:14:18,963
so for example if I was to take this last line here

383
00:14:19,263 --> 00:14:20,944
and put it up here at the top.

384
00:14:22,264 --> 00:14:23,704
now when I save the file.

385
00:14:23,764 --> 00:14:25,744
instead of just drawing up that triangle.

386
00:14:26,014 --> 00:14:27,034
it's going to draw out

387
00:14:27,064 --> 00:14:28,534
this little upside down

388
00:14:28,564 --> 00:14:30,154
bottom thing at the top and then

389
00:14:30,184 --> 00:14:31,864
the rest of the triangle down here so

390
00:14:32,194 --> 00:14:35,854
the order of the instructions actually matters a lot.

391
00:14:35,974 --> 00:14:39,154
so this is basically how your python programs are going to go.

392
00:14:39,214 --> 00:14:48,304
as we go through this course we're going to learn more and more of these little lines so here we're just using this little print function basically and just print something out on to the screen,

393
00:14:48,484 --> 00:14:51,634
there's a bunch of little things like this that we can learn as we go through

394
00:14:51,844 --> 00:14:55,504
will learn more and more instructions that we can give to the computer.

395
00:14:55,864 --> 00:14:58,984
but in this lesson I just wanted to kind of show you guys the basics right.

396
00:14:59,224 --> 00:14:59,674
oh

397
00:15:00,184 --> 00:15:03,934
we can essentially just define these little instructions for the computer

398
00:15:04,114 --> 00:15:06,004
and the computer will execute them

399
00:15:06,034 --> 00:15:06,694
in order.

400
00:15:10,504 --> 00:15:14,555
and this tutorial I wanna talk to you guys about using variables in

401
00:15:14,585 --> 00:15:15,395
python.

402
00:15:15,875 --> 00:15:17,945
now in python and you're going to be dealing with

403
00:15:17,975 --> 00:15:19,235
a lot of data

404
00:15:19,265 --> 00:15:21,935
and so a lot of times in our program we're going to be working with

405
00:15:21,965 --> 00:15:25,205
all types of information and data and values,

406
00:15:25,625 --> 00:15:27,005
and sometimes that data

407
00:15:27,035 --> 00:15:28,835
can be difficult to manage.

408
00:15:29,165 --> 00:15:32,465
so in python we have this thing called a variable.

409
00:15:32,705 --> 00:15:34,715
and it's basically just a container

410
00:15:34,985 --> 00:15:36,485
where we can store certain

411
00:15:36,515 --> 00:15:37,565
data values.

412
00:15:37,775 --> 00:15:40,055
and when we use a variable when we put those

413
00:15:40,115 --> 00:15:42,065
data values inside containers.

414
00:15:42,245 --> 00:15:43,145
it makes it a lot

415
00:15:43,175 --> 00:15:45,605
easier for us to work with and manage

416
00:15:45,635 --> 00:15:46,565
all of the different

417
00:15:46,595 --> 00:15:48,515
data inside of our programs.

418
00:15:48,815 --> 00:15:51,995
so variables are extremely helpful and it's sort of like a

419
00:15:52,025 --> 00:15:53,585
core topic in

420
00:15:53,735 --> 00:15:56,195
python that you're really going to want to know and master.

421
00:15:56,585 --> 00:15:58,655
so in this tutorial omelets each you guys.

422
00:15:58,745 --> 00:16:02,616
everything you need to know to get started with variables we're going to look at what they are

423
00:16:02,826 --> 00:16:05,916
why they're useful and we'll look at the different types of variables

424
00:16:05,946 --> 00:16:06,936
and the different types of

425
00:16:07,026 --> 00:16:08,616
data that we can store

426
00:16:08,646 --> 00:16:09,846
inside of variables,

427
00:16:10,026 --> 00:16:11,256
who over here in my

428
00:16:11,286 --> 00:16:13,806
python file I just have a very simple program.

429
00:16:14,196 --> 00:16:17,406
and it's basically just printing some text out onto the screen.

430
00:16:17,826 --> 00:16:20,556
and so this is actually a little story that I wrote it says.

431
00:16:20,796 --> 00:16:22,686
there once was a man named george

432
00:16:23,016 --> 00:16:24,636
he was seventy years old.

433
00:16:24,966 --> 00:16:26,646
he really liked the name george

434
00:16:26,826 --> 00:16:28,836
but didn't like being seventy.

435
00:16:29,166 --> 00:16:32,136
so this is a valid python program I can go ahead and

436
00:16:32,166 --> 00:16:33,156
run this program

437
00:16:33,546 --> 00:16:35,676
and you'll see down here in the council

438
00:16:35,706 --> 00:16:37,056
everything prints out and

439
00:16:37,116 --> 00:16:38,076
it looks great so

440
00:16:38,376 --> 00:16:40,386
we have an awesome little python program here.

441
00:16:40,806 --> 00:16:44,586
well let's say that inside of our story I wanted to change

442
00:16:44,617 --> 00:16:46,026
the character's name

443
00:16:46,057 --> 00:16:49,597
so instead of naming the character george let's say I wanted to name the character

444
00:16:49,627 --> 00:16:50,197
jon

445
00:16:50,617 --> 00:16:51,067
well

446
00:16:51,247 --> 00:16:59,557
I'm going to have to go through and I'm going to have to manually change the name george to the name john at every place inside of this story where it's mentioned.

447
00:16:59,647 --> 00:17:01,927
so I'm not to go over here and I'll say

448
00:17:01,957 --> 00:17:02,227
ok

449
00:17:02,257 --> 00:17:04,537
john I'm going to have to manually change that

450
00:17:04,777 --> 00:17:05,467
and then

451
00:17:05,497 --> 00:17:09,846
ok it's out here we're going up to again manually type in john and change it to john.

452
00:17:10,386 --> 00:17:15,606
so in order to change the character's name I had to manually go in and change it in both places.

453
00:17:16,086 --> 00:17:17,046
and now let's say

454
00:17:17,076 --> 00:17:17,376
ok

455
00:17:17,406 --> 00:17:19,626
maybe we want to change the characters ne

456
00:17:19,806 --> 00:17:22,446
age also so in addition to changing the name.

457
00:17:22,715 --> 00:17:28,656
we also want to change the age let's make him a little bit younger so why don't we say john is going to be thirty five.

458
00:17:29,406 --> 00:17:34,747
so you see here I had to come here and manually change the age and then come down here

459
00:17:35,017 --> 00:17:36,787
and manually change it again

460
00:17:37,207 --> 00:17:37,627
right.

461
00:17:38,017 --> 00:17:39,247
and now that we changed it like

462
00:17:39,277 --> 00:17:41,587
it's going to work it's going to be updated in our program.

463
00:17:41,977 --> 00:17:47,947
but you'll notice that in order to make that change like I had to look through the entire program find it where that

464
00:17:47,977 --> 00:17:49,597
value was and change it,

465
00:17:49,657 --> 00:17:50,077
and

466
00:17:50,137 --> 00:17:51,517
this was only with

467
00:17:51,547 --> 00:17:52,447
four lines

468
00:17:52,477 --> 00:17:55,357
of the story imagine if I had a story that was like

469
00:17:55,537 --> 00:17:57,067
thousands of lines long.

470
00:17:57,337 --> 00:17:59,017
and we mentioned that the character's name and

471
00:17:59,047 --> 00:17:59,707
age like

472
00:17:59,737 --> 00:18:00,847
hundreds of times.

473
00:18:01,177 --> 00:18:03,637
we don't have to look through each one of those lines and

474
00:18:03,847 --> 00:18:05,887
manually change the character's name

475
00:18:06,067 --> 00:18:09,127
and that is not a very good way for us to do this

476
00:18:09,487 --> 00:18:09,997
and

477
00:18:10,117 --> 00:18:14,077
it's really not a good way for us to manage the data in our program right the

478
00:18:14,107 --> 00:18:15,637
character's name in the age.

479
00:18:15,967 --> 00:18:18,187
and so we can actually use a variable

480
00:18:18,367 --> 00:18:19,777
in order to store

481
00:18:19,807 --> 00:18:21,788
the character's name and the characters.

482
00:18:21,848 --> 00:18:22,358
age.

483
00:18:22,568 --> 00:18:25,147
and when we use that variable it'll make it a lot

484
00:18:25,177 --> 00:18:27,758
easier for us to put the character's name and age.

485
00:18:27,818 --> 00:18:29,648
inside of our little program here.

486
00:18:30,038 --> 00:18:33,698
so I'm gonna show you guys how we can create a variable for the character's name and age.

487
00:18:33,998 --> 00:18:36,698
now it's going to go up here above this print statement.

488
00:18:37,088 --> 00:18:37,508
and

489
00:18:37,538 --> 00:18:40,238
up here I want to create a variable.

490
00:18:40,538 --> 00:18:42,518
so when we create a variable in

491
00:18:42,548 --> 00:18:44,828
python we actually need to give

492
00:18:45,008 --> 00:18:45,578
python

493
00:18:45,608 --> 00:18:47,228
a couple pieces of information.

494
00:18:47,708 --> 00:18:53,948
the first piece of information we need to give python is the name of the variable so I need to actually assign a name

495
00:18:54,128 --> 00:18:57,218
to this container where we're going to be storing information.

496
00:18:57,698 --> 00:18:59,528
so all I have to do is just type out

497
00:18:59,558 --> 00:19:00,818
the name of the variable

498
00:19:00,848 --> 00:19:02,708
that I want to create so I'm going to create a

499
00:19:02,798 --> 00:19:04,808
variable called character name.

500
00:19:05,288 --> 00:19:06,338
so I'm just going to say

501
00:19:07,028 --> 00:19:07,808
character

502
00:19:08,408 --> 00:19:09,758
adam's they underscore

503
00:19:09,788 --> 00:19:10,478
name

504
00:19:10,778 --> 00:19:12,998
so generally when you're creating a name

505
00:19:13,028 --> 00:19:14,738
for a variable in python.

506
00:19:14,888 --> 00:19:17,108
you want to separate different words

507
00:19:17,258 --> 00:19:21,788
with an underscore so I have two words here and I'm separating them with an underscore.

508
00:19:22,328 --> 00:19:24,249
and now what I need to do is I need to

509
00:19:24,279 --> 00:19:25,359
put a value

510
00:19:25,389 --> 00:19:27,399
inside of this very more so

511
00:19:27,459 --> 00:19:29,229
basically what I can do is I can just say

512
00:19:29,649 --> 00:19:30,459
equals

513
00:19:30,579 --> 00:19:32,439
and over here I can type a value

514
00:19:32,469 --> 00:19:34,839
so I'm just gonna type out the character's name inside of

515
00:19:35,019 --> 00:19:35,859
quotation marks.

516
00:19:36,159 --> 00:19:37,749
so we're just gonna type out john.

517
00:19:38,289 --> 00:19:41,499
so now we have a variable for the character's name

518
00:19:42,159 --> 00:19:46,629
and below this character named variable I want to create another variable called

519
00:19:46,719 --> 00:19:47,319
character

520
00:19:47,349 --> 00:19:49,149
age certain just going to tape out

521
00:19:49,719 --> 00:19:50,469
character

522
00:19:50,709 --> 00:19:51,459
underscore

523
00:19:51,519 --> 00:19:52,239
age.

524
00:19:52,599 --> 00:19:53,919
and I'm going to set this

525
00:19:53,949 --> 00:19:56,949
equal to the characters age which is thirty five.

526
00:19:58,120 --> 00:19:59,679
so we now have two variables,

527
00:19:59,949 --> 00:20:03,069
one representing the character's name and one representing the characters

528
00:20:03,099 --> 00:20:03,549
age.

529
00:20:03,819 --> 00:20:06,219
so what I can do now as I can replace

530
00:20:06,249 --> 00:20:08,559
the character's name inside of this story

531
00:20:08,589 --> 00:20:09,069
with

532
00:20:09,189 --> 00:20:10,359
this variable.

533
00:20:10,659 --> 00:20:12,130
and I'm gonna show you guys how to do that

534
00:20:12,160 --> 00:20:15,340
so if we want to put a variable inside of this print statement.

535
00:20:15,580 --> 00:20:17,500
I'm actually going to have to do a couple of things.

536
00:20:17,710 --> 00:20:19,840
the first thing I'm going to have to do is

537
00:20:20,020 --> 00:20:21,370
end off this

538
00:20:21,400 --> 00:20:23,380
text in here so I'm going to have to put

539
00:20:23,770 --> 00:20:24,220
a

540
00:20:24,280 --> 00:20:26,110
quotation marks here the end

541
00:20:26,410 --> 00:20:27,910
and you can see I'm basically

542
00:20:27,940 --> 00:20:29,890
wrapping this whole thing into a

543
00:20:29,950 --> 00:20:31,750
single like quoted line.

544
00:20:32,320 --> 00:20:36,760
and now I also have this tax overhear the end so I'm going to have to put a quotation mark here.

545
00:20:37,210 --> 00:20:37,990
so now I have

546
00:20:38,021 --> 00:20:38,470
a

547
00:20:38,531 --> 00:20:40,660
bunch of tax year in quotation marks.

548
00:20:41,080 --> 00:20:43,810
and then I also have tax over here in quotation marks

549
00:20:44,050 --> 00:20:45,520
now inside of here

550
00:20:45,610 --> 00:20:46,090
instead of

551
00:20:46,120 --> 00:20:47,650
saying the character's name

552
00:20:47,680 --> 00:20:49,750
I want to refer to that character name

553
00:20:49,780 --> 00:20:50,500
variable

554
00:20:50,920 --> 00:20:52,810
so I'm just going to say plus

555
00:20:54,430 --> 00:20:55,240
character

556
00:20:56,230 --> 00:20:57,340
underscore name

557
00:20:57,910 --> 00:21:01,421
and I want to say another plus sign so I basically I'm saying I want to

558
00:21:01,451 --> 00:21:03,100
print out all of this text,

559
00:21:03,641 --> 00:21:04,480
plus

560
00:21:04,661 --> 00:21:07,181
the value that stored inside of character name

561
00:21:07,511 --> 00:21:08,351
plus

562
00:21:08,651 --> 00:21:09,791
all of this text.

563
00:21:10,481 --> 00:21:14,021
and what this will do is they will actually print out the character's name we print this

564
00:21:14,291 --> 00:21:16,031
so I'm gonna go ahead and run this program

565
00:21:16,601 --> 00:21:18,041
and you'll see down here

566
00:21:18,101 --> 00:21:19,961
and actually let me put a space over here,

567
00:21:20,681 --> 00:21:21,641
and we'll run it again.

568
00:21:21,911 --> 00:21:23,381
so you can see down here,

569
00:21:23,561 --> 00:21:26,171
we still are printing out there once was a man named

570
00:21:26,201 --> 00:21:26,891
john.

571
00:21:27,491 --> 00:21:31,241
and so what python is doing is when it executes this line of code

572
00:21:31,541 --> 00:21:33,371
it's coming over here and it's seeing

573
00:21:33,461 --> 00:21:34,931
ok they want to turn out.

574
00:21:35,021 --> 00:21:37,331
the value inside of character name

575
00:21:37,661 --> 00:21:38,141
so it

576
00:21:38,171 --> 00:21:41,051
python's going to go up here it's going to get the value,

577
00:21:41,291 --> 00:21:41,801
and it's going to

578
00:21:41,831 --> 00:21:43,361
insert it inside of there

579
00:21:43,781 --> 00:21:48,611
so I can basically do this for every instance of the character name in my file so I can

580
00:21:48,911 --> 00:21:49,271
you know

581
00:21:49,331 --> 00:21:51,311
r is copy this guy right here

582
00:21:51,911 --> 00:21:52,421
and

583
00:21:52,481 --> 00:21:55,661
I can just paste it down here where the characters name is

584
00:21:55,871 --> 00:21:56,891
so apace this

585
00:21:57,071 --> 00:22:00,912
and you can see now were doing exactly the same thing that we did up there.

586
00:22:01,302 --> 00:22:03,792
I can also do this for the characters

587
00:22:03,852 --> 00:22:05,592
age someone to come down here

588
00:22:05,832 --> 00:22:07,872
and I'll paste in what we just paste it in.

589
00:22:08,832 --> 00:22:12,312
and I'm going to change this instead of character name was changed to character

590
00:22:12,342 --> 00:22:12,912
age.

591
00:22:14,502 --> 00:22:15,552
and I'm going to do this

592
00:22:15,582 --> 00:22:19,302
in one more spots are going to do this over here we're mentioning the age

593
00:22:19,992 --> 00:22:22,152
and again I'll just change this to

594
00:22:22,212 --> 00:22:22,482
carry

595
00:22:22,512 --> 00:22:23,142
your age.

596
00:22:23,832 --> 00:22:29,082
and so now when I run this program it's going to print out the same story they were printing out before,

597
00:22:29,502 --> 00:22:29,892
but

598
00:22:29,922 --> 00:22:34,632
now I don't actually have to type in the character's name and the characters age.

599
00:22:34,872 --> 00:22:36,312
I can just refer to this

600
00:22:36,342 --> 00:22:37,062
variable.

601
00:22:37,482 --> 00:22:41,352
and the cool thing about variables as if I wanted to change the character's name.

602
00:22:41,892 --> 00:22:46,212
now all I have to do is change it up here so I could change the characters names you like

603
00:22:46,242 --> 00:22:47,352
tom or something.

604
00:22:47,682 --> 00:22:49,902
and we could also change their age so I could change

605
00:22:50,052 --> 00:22:51,732
the age to be like fifty

606
00:22:52,032 --> 00:22:55,872
and now that's going to automatically update throughout our entire story

607
00:22:56,262 --> 00:22:58,002
when I click this play button you'll see

608
00:22:58,212 --> 00:23:00,312
now we're using the name tom

609
00:23:00,522 --> 00:23:02,382
and he's fifty years old.

610
00:23:02,652 --> 00:23:04,812
so that's where variables can come in handy and

611
00:23:04,842 --> 00:23:08,742
this can be a really awesome way to control and manage

612
00:23:08,982 --> 00:23:11,172
the data that's inside of our programs

613
00:23:11,592 --> 00:23:13,152
with variables you can also

614
00:23:13,182 --> 00:23:14,742
modify their values

615
00:23:14,772 --> 00:23:15,282
so

616
00:23:15,432 --> 00:23:19,602
for example let's say that halfway through the story I wanted to change the character's name

617
00:23:20,022 --> 00:23:22,122
why can just make some new lines over here,

618
00:23:22,482 --> 00:23:23,532
and down here

619
00:23:23,562 --> 00:23:25,452
I can actually assign a new

620
00:23:25,482 --> 00:23:27,222
value to one of these variables.

621
00:23:27,462 --> 00:23:28,662
so I can say like

622
00:23:29,532 --> 00:23:30,312
character

623
00:23:30,372 --> 00:23:31,512
underscore name,

624
00:23:31,962 --> 00:23:35,442
and in order to give it a different value all I have to do is just say equals

625
00:23:35,472 --> 00:23:37,182
and will give it a different value and so

626
00:23:37,693 --> 00:23:41,293
let's say halfway through the story we want to change the character's name to mike

627
00:23:42,313 --> 00:23:43,873
one now when I run my program

628
00:23:44,683 --> 00:23:47,263
you'll see here in the first part of the story it says

629
00:23:47,293 --> 00:23:48,433
there once was a man named

630
00:23:48,463 --> 00:23:49,123
tom.

631
00:23:49,453 --> 00:23:51,163
and in the second part of the story,

632
00:23:51,253 --> 00:23:53,083
it's referring to the name as

633
00:23:53,143 --> 00:23:53,803
mike.

634
00:23:54,013 --> 00:23:55,033
so I actually

635
00:23:55,063 --> 00:23:56,653
updated the variable

636
00:23:56,683 --> 00:23:58,153
inside of my program

637
00:23:58,183 --> 00:23:58,993
over here

638
00:23:59,383 --> 00:24:00,943
and that's a really awesome way

639
00:24:00,973 --> 00:24:05,533
you know a lot of times in these programs you're going to want to be modifying the values of variables

640
00:24:05,743 --> 00:24:06,553
so you can do it

641
00:24:06,583 --> 00:24:07,603
just like that.

642
00:24:07,663 --> 00:24:10,363
and so finally I want to talk to you guys about the different

643
00:24:10,573 --> 00:24:14,293
types of data that we can store inside of these variables.

644
00:24:14,593 --> 00:24:15,523
so over here

645
00:24:15,553 --> 00:24:18,073
I have the character name and character age

646
00:24:18,313 --> 00:24:18,643
and

647
00:24:18,703 --> 00:24:21,794
I'm actually storing what are called strings,

648
00:24:21,974 --> 00:24:24,314
so a string is basically just

649
00:24:24,524 --> 00:24:25,874
plain tax straight

650
00:24:26,114 --> 00:24:28,664
so the name tom that's just plain text

651
00:24:29,084 --> 00:24:31,574
down here these guys are strings as well.

652
00:24:31,844 --> 00:24:34,154
so there's a data type in python,

653
00:24:34,394 --> 00:24:36,554
called a string and it's just

654
00:24:36,584 --> 00:24:38,054
basically going to store

655
00:24:38,115 --> 00:24:38,955
plain text

656
00:24:38,985 --> 00:24:39,345
so

657
00:24:39,615 --> 00:24:43,185
you know any text that you would have like in a story early know someone's name

658
00:24:43,395 --> 00:24:45,344
you can store inside of a string.

659
00:24:45,885 --> 00:24:47,924
there's also another type of data

660
00:24:47,954 --> 00:24:49,935
that we can store inside of python

661
00:24:49,965 --> 00:24:51,075
which is numbers

662
00:24:51,105 --> 00:24:53,835
so an additional storing text we can also store

663
00:24:53,865 --> 00:24:54,495
numbers.

664
00:24:54,885 --> 00:24:57,165
so if I wanted to start a number for example

665
00:24:57,195 --> 00:25:00,705
let's say we wanted to store the character age instead of inside of a string.

666
00:25:01,005 --> 00:25:03,135
we can store it inside of a number so

667
00:25:03,915 --> 00:25:05,805
I could just type out fifty.

668
00:25:06,255 --> 00:25:09,915
and when we're storing a number we don't need these quotation marks

669
00:25:09,945 --> 00:25:11,625
you only need that quotation mark

670
00:25:11,895 --> 00:25:15,016
when you're storing a string so if I wanted to a number I can just

671
00:25:15,046 --> 00:25:16,216
write it out like this,

672
00:25:16,666 --> 00:25:20,295
and in addition to using whole numbers I can also use decimal numbers.

673
00:25:20,355 --> 00:25:23,205
so I could say like fifty point five six seven eight

674
00:25:23,235 --> 00:25:24,196
to one three

675
00:25:24,586 --> 00:25:26,536
and pythons are going to be able to store

676
00:25:26,566 --> 00:25:27,886
that number as well.

677
00:25:28,126 --> 00:25:29,956
you can store all different types of numbers

678
00:25:30,286 --> 00:25:32,206
and we can also store

679
00:25:32,236 --> 00:25:34,306
what's called a boolean value

680
00:25:34,576 --> 00:25:39,046
and a boolean value is essentially a true or false value.

681
00:25:39,376 --> 00:25:43,306
and there's a lot of instances in programming where we're going to want to represent

682
00:25:43,336 --> 00:25:44,566
true or false

683
00:25:44,626 --> 00:25:45,196
data

684
00:25:45,616 --> 00:25:47,836
for example I can have a variable called like

685
00:25:47,956 --> 00:25:48,976
his mail

686
00:25:49,306 --> 00:25:52,156
and this would tell me whether or not someone was a male,

687
00:25:52,486 --> 00:25:55,906
and in my case it will be true because I'm a guy right so I can

688
00:25:56,176 --> 00:25:57,346
actually this needs to be

689
00:25:57,376 --> 00:25:57,916
capital

690
00:25:58,756 --> 00:25:59,236
so

691
00:25:59,476 --> 00:26:01,876
I could sort of value of either true

692
00:26:02,416 --> 00:26:02,986
or

693
00:26:03,916 --> 00:26:04,696
false.

694
00:26:04,846 --> 00:26:07,036
and actually if we were naming this in python

695
00:26:07,066 --> 00:26:08,896
we want to use an underscore or so I would say

696
00:26:08,956 --> 00:26:10,546
is underscore mail

697
00:26:10,846 --> 00:26:12,706
and this can be either true or false

698
00:26:12,736 --> 00:26:13,126
so

699
00:26:13,366 --> 00:26:17,957
true or false values is maybe not something that you're used to dealing with like in the real world

700
00:26:18,497 --> 00:26:18,947
but

701
00:26:18,977 --> 00:26:22,007
in programming we're going to be using a true or false values

702
00:26:22,067 --> 00:26:24,707
all the time they're super important so

703
00:26:25,427 --> 00:26:29,537
like I said there's three basic types of data that we can work with in python there's

704
00:26:29,597 --> 00:26:32,117
strings which is just like a plain text,

705
00:26:32,177 --> 00:26:36,587
numbers which would be like either decimal numbers or whole numbers like this,

706
00:26:36,827 --> 00:26:38,207
and there's true or false

707
00:26:38,237 --> 00:26:38,927
values.

708
00:26:39,257 --> 00:26:45,857
and these are the basic types of data I mean there's a bunch of other types of data that we can use but I would say ninety nine percent of the time.

709
00:26:46,097 --> 00:26:47,597
as a new user

710
00:26:47,627 --> 00:26:49,398
in a new programmer to python,

711
00:26:49,608 --> 00:26:51,198
you're just going to be dealing with these

712
00:26:51,288 --> 00:26:52,668
three types of data

713
00:26:52,698 --> 00:26:53,118
so

714
00:26:53,388 --> 00:26:54,378
those are the basics

715
00:26:54,438 --> 00:26:55,398
of the data

716
00:26:55,428 --> 00:26:55,818
and

717
00:26:55,908 --> 00:26:57,228
also with variables

718
00:26:57,288 --> 00:26:58,548
and you're going to be using variables

719
00:26:58,578 --> 00:27:01,998
all the time in python so you definitely want to practice up and get comfortable

720
00:27:02,028 --> 00:27:02,748
using them

721
00:27:06,768 --> 00:27:11,298
in this tutorial are talks you guys about working with strings in python.

722
00:27:11,748 --> 00:27:13,458
now what the most common types of

723
00:27:13,488 --> 00:27:17,148
data that we're going to be working with in python is going to be strings

724
00:27:17,418 --> 00:27:19,308
and strings are basically just

725
00:27:19,428 --> 00:27:21,408
plain text so any text

726
00:27:21,708 --> 00:27:23,478
that we want to have inside of our program

727
00:27:23,688 --> 00:27:25,848
we can store inside of a string.

728
00:27:26,148 --> 00:27:30,318
so I wanna talk to you guys about all the cool things we can do with strings and we're basically just going to get a

729
00:27:30,558 --> 00:27:33,408
full introduction into why strings are awesome.

730
00:27:33,948 --> 00:27:34,938
so over here,

731
00:27:35,118 --> 00:27:36,918
I'm just going to actually print out

732
00:27:36,948 --> 00:27:39,109
a strings I'm just going to say print

733
00:27:39,529 --> 00:27:39,889
and

734
00:27:39,919 --> 00:27:41,359
inside of these parentheses.

735
00:27:41,419 --> 00:27:42,799
I can type out a string

736
00:27:43,219 --> 00:27:47,269
in order to create a string I need to use quotation marks so I can make an

737
00:27:47,299 --> 00:27:48,799
open and close quotation marks

738
00:27:48,829 --> 00:27:49,729
just like that

739
00:27:50,059 --> 00:27:50,389
now

740
00:27:50,449 --> 00:27:51,019
inside

741
00:27:51,049 --> 00:27:53,209
the quotation mark I can put whatever text

742
00:27:53,239 --> 00:27:55,549
I want the string to have so we could say like

743
00:27:56,059 --> 00:27:56,689
draff

744
00:27:56,749 --> 00:27:57,439
academy.

745
00:27:58,309 --> 00:27:59,989
and so now we have a string

746
00:28:00,019 --> 00:28:00,829
with the text

747
00:28:00,859 --> 00:28:02,359
draff academy inside of it

748
00:28:02,719 --> 00:28:04,129
so if I run my program.

749
00:28:04,249 --> 00:28:07,879
now down here we're going to print out draff academy as you can see,

750
00:28:08,059 --> 00:28:12,199
and when we have these strings there's actually a bunch of cool things that we can do with them so

751
00:28:12,499 --> 00:28:18,529
one thing I could do would be to create a new line inside of the string so if I wanted I could come over here,

752
00:28:18,799 --> 00:28:20,269
and I could save backslash

753
00:28:20,329 --> 00:28:20,870
n

754
00:28:21,290 --> 00:28:23,840
and you can see it got highlighted in a different color.

755
00:28:24,140 --> 00:28:30,320
and what this is gonna do is it's actually going to insert a new line into the string so now it's going to say draff on one line

756
00:28:30,530 --> 00:28:32,420
and academy on another line.

757
00:28:32,900 --> 00:28:34,400
so I'm gonna click play.

758
00:28:34,580 --> 00:28:37,130
and you'll see down here we just get draff academy,

759
00:28:37,520 --> 00:28:39,110
an addition to the backslash

760
00:28:39,140 --> 00:28:39,470
n

761
00:28:39,500 --> 00:28:40,910
I could also use

762
00:28:41,090 --> 00:28:42,110
a backslash

763
00:28:42,140 --> 00:28:43,430
quotation marks so

764
00:28:43,670 --> 00:28:46,760
if I wanted to put a quotation mark inside of my string.

765
00:28:47,180 --> 00:28:49,370
I can't just put a quotation mark like that

766
00:28:49,640 --> 00:28:52,371
because pythons going to think that I'm trying to end

767
00:28:52,401 --> 00:28:53,421
this strength.

768
00:28:53,691 --> 00:28:55,881
so if I want to include a quotation mark I can just use this

769
00:28:55,911 --> 00:28:57,531
special backslash character

770
00:28:57,981 --> 00:28:59,991
and that's called the escape character and it

771
00:29:00,021 --> 00:29:02,031
basically just tells python that

772
00:29:02,361 --> 00:29:05,391
whatever character comes after it we want to

773
00:29:05,452 --> 00:29:06,922
render a literally so

774
00:29:07,161 --> 00:29:08,572
when I say backslash

775
00:29:08,602 --> 00:29:09,472
quotation mark.

776
00:29:09,652 --> 00:29:10,522
it basically means like

777
00:29:10,552 --> 00:29:11,302
hey python

778
00:29:11,332 --> 00:29:12,772
I want to point out a quotation mark.

779
00:29:13,102 --> 00:29:14,572
and so now we'll be able to print

780
00:29:14,602 --> 00:29:14,842
out

781
00:29:14,872 --> 00:29:16,042
a quotation mark

782
00:29:16,072 --> 00:29:16,642
right there.

783
00:29:16,972 --> 00:29:20,752
I can also use this to print out of backslash so if I needed to put out a backslash.

784
00:29:20,812 --> 00:29:22,102
I could see backslash,

785
00:29:22,402 --> 00:29:22,912
and

786
00:29:23,152 --> 00:29:25,282
it'll just print out a normal backslash now

787
00:29:26,002 --> 00:29:27,622
so you can see just like that so

788
00:29:27,772 --> 00:29:29,752
if you want and you can use that backslash to make

789
00:29:29,782 --> 00:29:31,672
new lines or pronounce quotation marks,

790
00:29:31,943 --> 00:29:33,683
or you can just use it as a normal

791
00:29:33,713 --> 00:29:34,373
backslash

792
00:29:35,123 --> 00:29:39,503
in addition to just typing out a string here I could also create a string

793
00:29:39,533 --> 00:29:40,283
variable.

794
00:29:40,793 --> 00:29:41,933
so I could come down here

795
00:29:41,963 --> 00:29:44,423
up here and we can create a variable and let's call it

796
00:29:44,513 --> 00:29:45,443
phrase.

797
00:29:45,803 --> 00:29:46,523
and I'm going to set it

798
00:29:46,553 --> 00:29:47,543
equal to

799
00:29:47,633 --> 00:29:48,593
drop off a colony,

800
00:29:49,073 --> 00:29:49,763
so I can

801
00:29:49,823 --> 00:29:54,114
store this string value inside of a variable called phrase

802
00:29:54,384 --> 00:29:55,524
and then when I want to print

803
00:29:55,554 --> 00:29:56,664
out that variable,

804
00:29:56,754 --> 00:29:58,884
or I want to access that string variable.

805
00:29:59,094 --> 00:29:59,844
I can just

806
00:30:00,024 --> 00:30:01,344
type the name of

807
00:30:01,404 --> 00:30:02,184
the variable.

808
00:30:02,394 --> 00:30:06,204
and you'll see that it's going to print out the value that was stored inside of it.

809
00:30:06,564 --> 00:30:09,534
I can also use something called concatenation

810
00:30:09,774 --> 00:30:13,464
and concatenation is basically the process of taking a string and

811
00:30:13,644 --> 00:30:15,504
appending another string onto it.

812
00:30:15,834 --> 00:30:18,144
so I could come over here and I could say phrase,

813
00:30:18,414 --> 00:30:18,894
and I can say

814
00:30:18,924 --> 00:30:19,734
plus.

815
00:30:19,884 --> 00:30:23,035
and now I can add in another string so I could say like

816
00:30:23,305 --> 00:30:24,205
is cool.

817
00:30:24,445 --> 00:30:25,795
and now this is going to say

818
00:30:25,825 --> 00:30:26,995
druff academy

819
00:30:27,025 --> 00:30:27,625
is

820
00:30:27,655 --> 00:30:28,195
cool,

821
00:30:28,675 --> 00:30:31,345
so I'm basically appending another string

822
00:30:31,435 --> 00:30:33,655
onto another one they call that concatenation.

823
00:30:34,045 --> 00:30:38,815
and so in addition to doing all that stuff we can also use a special thing is called

824
00:30:38,845 --> 00:30:39,745
functions

825
00:30:40,045 --> 00:30:43,945
and a function is basically just a little block of code that we can run

826
00:30:44,215 --> 00:30:45,865
and it will perform a specific

827
00:30:45,895 --> 00:30:47,275
operation for us,

828
00:30:47,515 --> 00:30:50,756
so we can use functions to modify our strings.

829
00:30:50,996 --> 00:30:55,046
we can also use functions to get information about our strings.

830
00:30:55,256 --> 00:30:55,736
so

831
00:30:55,886 --> 00:30:59,486
I'm gonna show you guys a couple common functions we can use with the strings.

832
00:30:59,756 --> 00:31:00,086
and

833
00:31:00,116 --> 00:31:02,156
they're actually going to do awesome stuff so

834
00:31:02,426 --> 00:31:06,146
in order to access one of these functions I can just say phrase and then I can say

835
00:31:06,176 --> 00:31:06,716
dot.

836
00:31:07,016 --> 00:31:07,376
and

837
00:31:07,466 --> 00:31:10,586
I'm gonna show you guys a function that we can use to convert this

838
00:31:10,616 --> 00:31:14,786
string entirely into lowercase so I could just say phrase dot lower.

839
00:31:15,116 --> 00:31:16,136
and I'm going to want to type an

840
00:31:16,166 --> 00:31:17,786
open and close parentheses,

841
00:31:17,996 --> 00:31:19,706
and this will take this phrase,

842
00:31:19,826 --> 00:31:22,526
it'll take my string and it will convert it to lower case.

843
00:31:22,706 --> 00:31:27,086
so you can see now we just have a draft academy done here but it's entirely in lower case.

844
00:31:27,356 --> 00:31:31,076
I could also do the same thing for upper case so I could say phrase dot

845
00:31:31,196 --> 00:31:31,766
upper

846
00:31:32,216 --> 00:31:34,586
and this will convert the entire string into

847
00:31:34,616 --> 00:31:36,116
upper case so you can see now it's

848
00:31:36,146 --> 00:31:37,406
entirely upper case.

849
00:31:37,466 --> 00:31:38,996
so in addition to

850
00:31:39,026 --> 00:31:40,587
converting the string into upper case

851
00:31:40,617 --> 00:31:41,157
lower case

852
00:31:41,187 --> 00:31:41,727
I can also

853
00:31:41,757 --> 00:31:46,167
check to see if a string is entirely upper case are entirely lowercase.

854
00:31:46,617 --> 00:31:48,627
so for example I could say phrase dot

855
00:31:48,657 --> 00:31:49,647
is upper.

856
00:31:49,917 --> 00:31:53,517
and this is going to give me back a true or false value

857
00:31:53,547 --> 00:31:54,837
so it's going to be true

858
00:31:55,077 --> 00:31:57,057
if the string is entirely upper case

859
00:31:57,087 --> 00:31:57,777
or false

860
00:31:57,807 --> 00:31:58,617
if it's not.

861
00:31:59,097 --> 00:32:02,067
and you can see here we're getting a false value because this

862
00:32:02,097 --> 00:32:02,457
is an

863
00:32:02,487 --> 00:32:03,207
upper case

864
00:32:03,747 --> 00:32:08,817
I can also use these functions in combination with each other so for example,

865
00:32:08,877 --> 00:32:10,647
I could say phrase

866
00:32:11,457 --> 00:32:11,907
dot

867
00:32:11,967 --> 00:32:12,627
upper

868
00:32:13,017 --> 00:32:13,557
and that a

869
00:32:13,617 --> 00:32:14,577
parentheses

870
00:32:14,937 --> 00:32:16,647
and then after this I can say

871
00:32:16,677 --> 00:32:17,037
dot

872
00:32:17,068 --> 00:32:17,698
is upper

873
00:32:17,728 --> 00:32:20,398
and now what it's going to do is it's going to run this

874
00:32:20,428 --> 00:32:21,418
upper function,

875
00:32:21,628 --> 00:32:23,458
it's going to convert it into upper case.

876
00:32:23,638 --> 00:32:24,928
and then it's going to run this

877
00:32:24,988 --> 00:32:27,088
is upper function right after that

878
00:32:27,208 --> 00:32:33,028
and you'll see now we're going to get a true value back because it will have converted the whole thing into upper case.

879
00:32:33,298 --> 00:32:36,058
so you can see now we're getting a true value so

880
00:32:36,388 --> 00:32:37,468
the news these functions

881
00:32:37,498 --> 00:32:39,808
one after another it can be really useful.

882
00:32:40,318 --> 00:32:43,379
and there's a few other ones that I want to show you so we can also

883
00:32:43,469 --> 00:32:44,849
figure out the length

884
00:32:44,909 --> 00:32:45,329
of

885
00:32:45,389 --> 00:32:46,829
this string so

886
00:32:47,159 --> 00:32:50,099
if I wanted to figure out how many characters were inside of this

887
00:32:50,129 --> 00:32:51,509
string I could just say

888
00:32:51,539 --> 00:32:52,349
l e n

889
00:32:52,709 --> 00:32:53,759
and I'm actually going to make an

890
00:32:53,789 --> 00:32:54,959
open parentheses,

891
00:32:55,169 --> 00:32:57,149
and I'm going to make a close parentheses.

892
00:32:57,389 --> 00:32:58,679
so I'm essentially saying

893
00:32:58,709 --> 00:33:01,859
alien and this is another function it's the length function.

894
00:33:02,129 --> 00:33:05,519
and inside of this alien function I'm actually passing

895
00:33:05,549 --> 00:33:06,059
this

896
00:33:06,269 --> 00:33:07,529
phrase variable

897
00:33:07,829 --> 00:33:12,509
basically giving the length function this and it's going to spit out a number so tell me how many

898
00:33:12,569 --> 00:33:14,369
characters are inside of this string.

899
00:33:15,059 --> 00:33:20,639
as you can see here we get fifteen because there's fifteen characters inside of draff academy.

900
00:33:20,999 --> 00:33:25,889
so that's how you can get the whole length of the string and that's going to be really useful as we go forward in python.

901
00:33:25,949 --> 00:33:26,969
we can also get

902
00:33:26,999 --> 00:33:29,789
individual characters inside of a string so

903
00:33:30,089 --> 00:33:34,589
imagine if I wanted to just grab one of these characters like imagine if I wanted to

904
00:33:34,619 --> 00:33:37,379
figure out what the first character in the string is

905
00:33:37,739 --> 00:33:38,969
we're going to actually use

906
00:33:39,029 --> 00:33:40,020
and open a closed

907
00:33:40,050 --> 00:33:41,190
square bracket

908
00:33:41,220 --> 00:33:42,120
just like that.

909
00:33:42,360 --> 00:33:44,340
and in here I can specify the

910
00:33:44,370 --> 00:33:46,620
index of the character that I want to graph.

911
00:33:46,920 --> 00:33:49,860
so if I wanted to grab the first character in the string

912
00:33:49,890 --> 00:33:51,390
I can put in a zero.

913
00:33:51,690 --> 00:33:53,100
so if I say phrase

914
00:33:53,130 --> 00:33:54,570
square bracket zero,

915
00:33:54,750 --> 00:33:57,060
this is going to give me that capital g

916
00:33:57,300 --> 00:33:58,710
and you can see down here

917
00:33:58,740 --> 00:34:00,090
that's what gets printed out.

918
00:34:00,450 --> 00:34:01,771
now I want to point something out

919
00:34:01,860 --> 00:34:02,401
in

920
00:34:02,521 --> 00:34:03,421
python.

921
00:34:03,541 --> 00:34:05,131
when we're working with strings.

922
00:34:05,461 --> 00:34:06,211
a string

923
00:34:06,241 --> 00:34:07,141
gets indexed

924
00:34:07,171 --> 00:34:08,460
starting with zero.

925
00:34:08,730 --> 00:34:11,700
so you'll notice that in order to access this g.

926
00:34:11,791 --> 00:34:13,501
I had to put a zero in here.

927
00:34:13,801 --> 00:34:15,361
that's because in python.

928
00:34:15,781 --> 00:34:18,931
when we use indexes on a string we start with zero

929
00:34:19,170 --> 00:34:21,840
so if python is counting the characters

930
00:34:22,051 --> 00:34:25,771
or its indexing the characters in a string it's going to start with zero so it's going to say

931
00:34:25,981 --> 00:34:27,001
g is zero

932
00:34:27,360 --> 00:34:28,980
I as one are as to

933
00:34:29,011 --> 00:34:29,761
a history.

934
00:34:30,061 --> 00:34:32,431
so we would say that g is at position

935
00:34:32,460 --> 00:34:33,870
zero in the string.

936
00:34:33,931 --> 00:34:35,402
I is at position one

937
00:34:35,732 --> 00:34:36,962
r is at position two

938
00:34:36,992 --> 00:34:38,702
a's at position three etc.

939
00:34:38,942 --> 00:34:40,382
so we start counting

940
00:34:40,411 --> 00:34:41,461
at zero.

941
00:34:42,302 --> 00:34:43,712
so if I wanted to access

942
00:34:43,952 --> 00:34:44,672
the first

943
00:34:45,121 --> 00:34:46,412
character in the string.

944
00:34:46,592 --> 00:34:48,752
this g I have to say phrase

945
00:34:48,783 --> 00:34:50,613
zero and that's just a special thing

946
00:34:51,062 --> 00:34:53,942
in python and actually most programming languages

947
00:34:53,972 --> 00:34:55,322
do that so they'll start with

948
00:34:55,351 --> 00:34:55,981
zero.

949
00:34:56,342 --> 00:34:58,262
so for example if I wanted to access this

950
00:34:58,292 --> 00:34:58,802
ei,

951
00:34:59,042 --> 00:35:00,002
I'm going to have to put

952
00:35:00,032 --> 00:35:00,873
zero

953
00:35:02,493 --> 00:35:03,033
one

954
00:35:03,063 --> 00:35:06,213
two three so I put three inside of here

955
00:35:06,453 --> 00:35:08,643
now will be able to access that first

956
00:35:08,703 --> 00:35:09,123
a.

957
00:35:09,363 --> 00:35:10,474
as you can see we get an

958
00:35:10,504 --> 00:35:11,434
a right here,

959
00:35:11,824 --> 00:35:12,784
so this

960
00:35:12,844 --> 00:35:16,924
is actually really useful being able to grab a specific character inside of a string

961
00:35:16,984 --> 00:35:17,914
and you're gonna be using it

962
00:35:17,944 --> 00:35:19,895
that a lot as we go forward and python

963
00:35:20,015 --> 00:35:23,795
is also another really awesome function that we can use and it's called the

964
00:35:23,825 --> 00:35:24,905
index function.

965
00:35:25,685 --> 00:35:28,895
and basically what the index function will do is it'll tell us

966
00:35:28,925 --> 00:35:30,635
where a specific

967
00:35:30,666 --> 00:35:33,335
character or string is located

968
00:35:33,365 --> 00:35:35,615
inside of our strings like unsafe phrase

969
00:35:36,005 --> 00:35:36,335
dot

970
00:35:36,365 --> 00:35:37,085
index.

971
00:35:37,415 --> 00:35:37,895
and

972
00:35:38,105 --> 00:35:42,906
I can actually give this a value so sometimes when we use these functions in python,

973
00:35:43,146 --> 00:35:45,966
we can actually give them information so I can give this

974
00:35:45,996 --> 00:35:46,746
of value

975
00:35:47,076 --> 00:35:50,286
and we would call this passing a parameter so

976
00:35:50,376 --> 00:35:53,076
I would call a value that I would give to a function

977
00:35:53,106 --> 00:35:55,266
a parameter and you'll hear that word a lot.

978
00:35:55,656 --> 00:35:56,346
so

979
00:35:56,436 --> 00:35:58,686
for example I can say inside of here

980
00:35:58,716 --> 00:35:59,886
capitol g,

981
00:36:00,066 --> 00:36:01,926
and now this is going to return

982
00:36:01,956 --> 00:36:02,826
the index

983
00:36:02,856 --> 00:36:03,276
of

984
00:36:03,306 --> 00:36:05,526
the capitol g inside of our string

985
00:36:05,736 --> 00:36:07,236
so it should give us back

986
00:36:07,266 --> 00:36:09,907
a zero because g is at the zero of index

987
00:36:10,267 --> 00:36:13,717
and you'll see down here that we get a zero because that's where g is.

988
00:36:14,137 --> 00:36:15,847
so for example if I put in

989
00:36:15,877 --> 00:36:17,677
a inside it here like the lower case

990
00:36:17,707 --> 00:36:18,037
a

991
00:36:18,067 --> 00:36:21,247
it should give me zero one two three

992
00:36:21,457 --> 00:36:22,987
because that's where the first

993
00:36:23,047 --> 00:36:24,697
aid is inside of this string,

994
00:36:25,207 --> 00:36:26,527
so I can click the play button

995
00:36:26,917 --> 00:36:28,327
and you'll see it's giving us

996
00:36:28,357 --> 00:36:28,957
a three.

997
00:36:29,257 --> 00:36:32,647
you can also put actual words in here so for example I could put like

998
00:36:32,948 --> 00:36:34,177
academy in here,

999
00:36:34,448 --> 00:36:35,857
or I could even just put like

1000
00:36:35,917 --> 00:36:37,208
a c a d.

1001
00:36:37,508 --> 00:36:40,507
and this is going to tell me where this starts

1002
00:36:40,537 --> 00:36:42,787
inside of my string so when I click play,

1003
00:36:43,177 --> 00:36:43,957
it's going to give me an

1004
00:36:43,987 --> 00:36:44,287
a

1005
00:36:44,317 --> 00:36:44,887
because

1006
00:36:44,917 --> 00:36:45,698
that's where

1007
00:36:45,758 --> 00:36:47,138
a cat and he starts right

1008
00:36:47,438 --> 00:36:49,928
zero one two three four five six seven

1009
00:36:49,958 --> 00:36:50,319
eight

1010
00:36:51,129 --> 00:36:55,749
if I put something in here that wasn't in the strings of for example if I put a z in here,

1011
00:36:56,109 --> 00:36:57,039
that's not in here.

1012
00:36:57,129 --> 00:37:01,389
it's actually going to throw an error so when I play this you'll see that we get this error down here

1013
00:37:01,419 --> 00:37:01,839
because

1014
00:37:01,989 --> 00:37:04,809
the z is not found inside of our program so

1015
00:37:04,959 --> 00:37:08,709
that the next function again can be really useful we'll be using that a lot.

1016
00:37:08,769 --> 00:37:11,049
there's also one more than I want to show you which

1017
00:37:11,079 --> 00:37:12,579
is called replace

1018
00:37:12,609 --> 00:37:15,010
so we can say phrase not replace

1019
00:37:15,310 --> 00:37:17,410
and in here I can actually give this

1020
00:37:17,440 --> 00:37:20,440
two parameters so I can give this replace function

1021
00:37:20,770 --> 00:37:22,510
two values that it can use.

1022
00:37:22,750 --> 00:37:24,100
and the first thing I want to you

1023
00:37:24,130 --> 00:37:27,221
to give it is what I want to replace so for example I could say

1024
00:37:27,251 --> 00:37:27,941
giraffe.

1025
00:37:28,421 --> 00:37:30,341
and then I'm going to put a comma in here,

1026
00:37:30,611 --> 00:37:33,101
and I want to put in here what I want to replace

1027
00:37:33,131 --> 00:37:35,260
draft with so I could just say like

1028
00:37:35,381 --> 00:37:36,041
elephant

1029
00:37:36,401 --> 00:37:39,641
and now instead of saying draff academy this is going to print out

1030
00:37:39,671 --> 00:37:40,901
elephant academy.

1031
00:37:41,321 --> 00:37:43,991
so you can see down here it just says elephant academy so

1032
00:37:44,201 --> 00:37:45,161
this replace

1033
00:37:45,191 --> 00:37:45,701
function

1034
00:37:45,731 --> 00:37:46,181
can be

1035
00:37:46,211 --> 00:37:47,831
really awesome because we can replace

1036
00:37:48,041 --> 00:37:48,641
certain

1037
00:37:48,911 --> 00:37:50,802
words or even certain letters

1038
00:37:50,832 --> 00:37:52,092
inside of our springs with

1039
00:37:52,182 --> 00:37:52,842
other ones.

1040
00:37:52,932 --> 00:37:58,002
so those are some basic ways that we can work with strings inside of python

1041
00:37:58,032 --> 00:37:58,302
and

1042
00:37:58,542 --> 00:38:01,842
there's a lot of these different functions that we can use with strings.

1043
00:38:02,052 --> 00:38:05,202
these are some of the most common the ones that I just showed you right now,

1044
00:38:05,472 --> 00:38:08,263
but if you just do a google search you can find all sorts of

1045
00:38:08,503 --> 00:38:11,353
python functions that you can try out in use and you know,

1046
00:38:11,563 --> 00:38:12,523
see what they do,

1047
00:38:12,913 --> 00:38:17,322
but you definitely want to get comfortable working with strings and python because you're going to be working with them

1048
00:38:17,352 --> 00:38:17,892
a lot.

1049
00:38:21,912 --> 00:38:25,902
in this tutorial I wanna talk to you about working with numbers in

1050
00:38:25,962 --> 00:38:26,652
python

1051
00:38:27,042 --> 00:38:28,362
and numbers are one most

1052
00:38:28,392 --> 00:38:30,882
common data types in python and

1053
00:38:31,212 --> 00:38:35,173
any python program you write is most likely going to be dealing with numbers at

1054
00:38:35,203 --> 00:38:36,073
some point

1055
00:38:36,103 --> 00:38:36,403
so

1056
00:38:36,703 --> 00:38:43,003
I want to talk to you guys about the basics of using numbers we can talk about the different types of numbers that we can represent in python.

1057
00:38:43,453 --> 00:38:44,924
and I also want to show you guys some

1058
00:38:44,954 --> 00:38:51,194
awesome functions that we can use with number so we can do a certain like mathematical operations mechanism

1059
00:38:51,224 --> 00:38:52,214
awesome things

1060
00:38:52,484 --> 00:38:54,014
with numbers I'm going to show you guys

1061
00:38:54,044 --> 00:38:56,385
all of that in this video it's gonna be awesome so

1062
00:38:57,014 --> 00:38:58,034
first thing we can do is

1063
00:38:58,334 --> 00:39:00,375
we can actually just like print out a number.

1064
00:39:00,615 --> 00:39:05,865
so if I want to write a number in python it's really easy I basically just write the number so I could say like print

1065
00:39:05,896 --> 00:39:06,466
too.

1066
00:39:06,796 --> 00:39:10,096
and this is just going to print the number two out onto the screen,

1067
00:39:10,666 --> 00:39:15,977
so I can use a whole number like this I could also use a decimal number so I can say like two point

1068
00:39:16,007 --> 00:39:17,237
oh nine eight seven

1069
00:39:17,657 --> 00:39:20,988
and pythons are gonna be just fine with that we'll be able to print that on

1070
00:39:21,018 --> 00:39:21,918
the screen as well.

1071
00:39:22,368 --> 00:39:23,658
I can also make numbers

1072
00:39:23,688 --> 00:39:25,428
negative so I could make this

1073
00:39:25,458 --> 00:39:25,908
two point

1074
00:39:25,938 --> 00:39:26,418
oh nine

1075
00:39:26,478 --> 00:39:27,168
eight seven

1076
00:39:27,198 --> 00:39:28,668
a negative number and

1077
00:39:28,968 --> 00:39:31,548
python to be able to handle that just fine too.

1078
00:39:32,358 --> 00:39:35,057
in python we can also use

1079
00:39:35,117 --> 00:39:39,048
basic arithmetic so I could do things like addition subtraction multiplication

1080
00:39:39,348 --> 00:39:40,008
fancy like

1081
00:39:40,038 --> 00:39:40,638
three

1082
00:39:40,668 --> 00:39:41,868
plus four

1083
00:39:41,958 --> 00:39:45,108
and now this is going to print this out or was he like three plus

1084
00:39:45,138 --> 00:39:46,428
four point five.

1085
00:39:46,999 --> 00:39:50,509
and this will be able to print out the answer so we get seven point five.

1086
00:39:50,779 --> 00:39:53,149
and we can do a dish in we can do subtraction.

1087
00:39:53,479 --> 00:39:54,530
we can do division

1088
00:39:54,560 --> 00:39:56,930
or we could do like multiplication as well so you can

1089
00:39:56,960 --> 00:39:59,690
pretty much do whatever you want inside of python,

1090
00:40:00,170 --> 00:40:05,031
and if you want to make more complex mathematical equations we can also use

1091
00:40:05,571 --> 00:40:08,121
things to specify order of operations

1092
00:40:08,151 --> 00:40:09,591
so I could use parentheses.

1093
00:40:10,071 --> 00:40:13,730
so for example if I said three times four plus five

1094
00:40:14,601 --> 00:40:23,031
what python is gonna do is it's gonna multiply three and four together so it's going to be twelve and then we'll add five to that so we should get seventeen.

1095
00:40:24,201 --> 00:40:26,301
but let's say that we wanted to change up the order

1096
00:40:26,331 --> 00:40:26,631
right

1097
00:40:26,661 --> 00:40:29,991
I could actually put a parentheses around four and five

1098
00:40:30,501 --> 00:40:31,401
and now

1099
00:40:31,461 --> 00:40:38,391
it's going to add them first social ad foreign fighters will get nine and will multiply that times three so we should end up with twenty seven,

1100
00:40:38,871 --> 00:40:45,141
so you can see we can use those parentheses to specify order of operations so I could make like a very complex

1101
00:40:45,711 --> 00:40:49,011
little equation here and just by using numbers and parentheses.

1102
00:40:49,161 --> 00:40:50,421
we can also

1103
00:40:50,481 --> 00:40:54,861
use one other operation which is called the modulates operator so I could say like

1104
00:40:54,891 --> 00:40:55,641
ted,

1105
00:40:55,941 --> 00:40:57,741
and use this percent sign

1106
00:40:58,011 --> 00:40:59,961
three and this is actually read

1107
00:40:59,991 --> 00:41:00,501
ten

1108
00:41:00,531 --> 00:41:01,221
mod

1109
00:41:01,251 --> 00:41:01,791
three

1110
00:41:02,181 --> 00:41:05,211
and basically what this is gonna do is it's going to take the first number

1111
00:41:05,421 --> 00:41:07,221
divided by the second number,

1112
00:41:07,312 --> 00:41:09,232
and it's going to spit out the remainder.

1113
00:41:09,472 --> 00:41:10,552
so it's basically going to say

1114
00:41:10,582 --> 00:41:10,912
ok

1115
00:41:10,942 --> 00:41:12,562
ten divided by three.

1116
00:41:12,772 --> 00:41:14,062
that's going to be three

1117
00:41:14,092 --> 00:41:15,562
with a remainder of one.

1118
00:41:15,832 --> 00:41:17,872
so this is going to give us the remainder.

1119
00:41:18,172 --> 00:41:18,682
and

1120
00:41:18,742 --> 00:41:20,932
you'll see down here we get one because

1121
00:41:20,962 --> 00:41:23,422
that's the remainder of ten divided by three

1122
00:41:23,692 --> 00:41:26,512
that modulates operator can come in handy quite a bit.

1123
00:41:26,662 --> 00:41:28,192
we can also store these

1124
00:41:28,852 --> 00:41:30,623
numbers inside of variables

1125
00:41:30,653 --> 00:41:32,393
so we can store them inside of these

1126
00:41:32,423 --> 00:41:33,653
variable containers,

1127
00:41:33,923 --> 00:41:34,523
so I could

1128
00:41:34,553 --> 00:41:35,573
come over here

1129
00:41:35,663 --> 00:41:37,523
and I could create a variable called like

1130
00:41:37,613 --> 00:41:39,143
my underscored gnome

1131
00:41:39,833 --> 00:41:41,663
and we'll just store a value

1132
00:41:41,693 --> 00:41:43,313
of let's say like five and here

1133
00:41:43,673 --> 00:41:47,364
is why have you come down here and I can just print out my underscore numb.

1134
00:41:47,694 --> 00:41:50,154
and we'll be able to print that number out to the screen

1135
00:41:50,184 --> 00:41:50,964
just fine.

1136
00:41:51,114 --> 00:41:54,054
so in addition to doing things like a basic arithmetic

1137
00:41:54,084 --> 00:41:55,584
we can also

1138
00:41:55,734 --> 00:42:00,923
do some other stuff so one thing I could do is I could actually convert this number into a string.

1139
00:42:01,283 --> 00:42:05,244
so if I wanted to convert this number into a string I can just say s t r

1140
00:42:05,664 --> 00:42:08,274
and I can put the number that I want to convert

1141
00:42:08,304 --> 00:42:10,134
inside of these parentheses.

1142
00:42:10,434 --> 00:42:14,125
and so what's going to happen now is this number is going to be converted

1143
00:42:14,425 --> 00:42:14,905
into

1144
00:42:14,935 --> 00:42:16,434
a strings when I click

1145
00:42:16,554 --> 00:42:17,694
the run button you'll see it's

1146
00:42:17,904 --> 00:42:22,434
just printing out five but now instead of being a number this is actually a string.

1147
00:42:22,764 --> 00:42:26,814
and this is going to come in handy when you want to print out numbers alongside

1148
00:42:26,844 --> 00:42:27,715
strings,

1149
00:42:28,045 --> 00:42:29,995
so I can come over here and I can say like

1150
00:42:30,475 --> 00:42:31,195
my

1151
00:42:32,245 --> 00:42:33,415
favorite number,

1152
00:42:33,895 --> 00:42:35,395
and we'll be able to print this

1153
00:42:35,425 --> 00:42:37,345
number along with this

1154
00:42:37,375 --> 00:42:39,085
string so I click play,

1155
00:42:39,295 --> 00:42:41,155
and it's as five my favorite number,

1156
00:42:41,485 --> 00:42:43,314
if I was to get rid of this

1157
00:42:43,344 --> 00:42:44,094
string

1158
00:42:44,155 --> 00:42:44,814
right here

1159
00:42:44,844 --> 00:42:47,515
and I wasn't converting the number into a string.

1160
00:42:47,815 --> 00:42:49,855
now pythons gonna have a problem with this.

1161
00:42:50,035 --> 00:42:52,585
it's not going to allow us to do that you can see we get an

1162
00:42:52,615 --> 00:42:53,305
error so

1163
00:42:53,545 --> 00:42:55,255
anytime you want to print out a number

1164
00:42:55,285 --> 00:42:59,245
next to a string you gotta make sure that you use that little string function.

1165
00:42:59,995 --> 00:43:00,445
so

1166
00:43:00,475 --> 00:43:03,505
there's a bunch of other stuff that we can do with numbers and

1167
00:43:03,625 --> 00:43:05,096
a lot of times in python

1168
00:43:05,126 --> 00:43:07,315
you're gonna want to be using specific

1169
00:43:07,345 --> 00:43:10,135
metabolic more advanced math operator so

1170
00:43:10,525 --> 00:43:12,145
there's a bunch of different math

1171
00:43:12,175 --> 00:43:14,605
functions that we can use on our numbers

1172
00:43:14,815 --> 00:43:19,435
and a function is basically just like a little collection of code that does something so

1173
00:43:19,705 --> 00:43:24,235
a function could perform an operation like a mathematical operation on our number,

1174
00:43:24,715 --> 00:43:27,385
we can also give us information about our number,

1175
00:43:27,625 --> 00:43:32,036
so I'm sure you guys some of the most common functions that you'll be using in python

1176
00:43:32,066 --> 00:43:33,176
related to numbers.

1177
00:43:33,746 --> 00:43:35,456
the first one is called

1178
00:43:35,906 --> 00:43:36,626
abs

1179
00:43:36,656 --> 00:43:40,255
and it stands for absolute value so we can get the absolute value

1180
00:43:40,555 --> 00:43:41,005
of

1181
00:43:41,035 --> 00:43:41,666
a number.

1182
00:43:42,476 --> 00:43:43,676
and so over here I'm going to

1183
00:43:43,706 --> 00:43:45,656
make this variable negative five

1184
00:43:46,135 --> 00:43:47,396
and basically I can just say

1185
00:43:47,426 --> 00:43:48,385
abs

1186
00:43:48,476 --> 00:43:49,106
and I can make an

1187
00:43:49,166 --> 00:43:51,146
open enclosing parentheses over here,

1188
00:43:51,536 --> 00:43:54,445
and this is going to give me the absolute value of

1189
00:43:54,475 --> 00:43:55,825
this number up here,

1190
00:43:56,215 --> 00:43:57,655
so when I click the play button,

1191
00:43:57,925 --> 00:44:03,445
you'll see it's just giving us five because five is the absolute value of negative five,

1192
00:44:03,625 --> 00:44:06,205
I can use a few other functions there is another one

1193
00:44:06,235 --> 00:44:07,105
which is called

1194
00:44:07,225 --> 00:44:09,745
pau at so it says p o w

1195
00:44:10,105 --> 00:44:12,956
and I'm actually not going to use this variable we just as a normal number

1196
00:44:13,436 --> 00:44:13,766
and

1197
00:44:13,796 --> 00:44:16,166
this function is going to allow us to pass it

1198
00:44:16,226 --> 00:44:19,346
to pieces of information so I can give this function

1199
00:44:19,376 --> 00:44:20,606
two pieces of information.

1200
00:44:20,967 --> 00:44:22,227
the first is going to be

1201
00:44:22,646 --> 00:44:23,636
like a number.

1202
00:44:23,816 --> 00:44:28,827
and the second is going to be the power that I want to take that number two so I could say like three

1203
00:44:29,187 --> 00:44:29,727
comma

1204
00:44:29,757 --> 00:44:30,327
two

1205
00:44:30,597 --> 00:44:32,517
and this is basically just going to be

1206
00:44:32,577 --> 00:44:33,297
three

1207
00:44:33,327 --> 00:44:34,917
raised to the power of two,

1208
00:44:35,217 --> 00:44:35,757
so

1209
00:44:35,817 --> 00:44:38,817
it's just going to be three squared so we should get nine down here,

1210
00:44:39,177 --> 00:44:40,167
you can see that we do,

1211
00:44:40,557 --> 00:44:41,787
so I could pass in like

1212
00:44:41,817 --> 00:44:42,177
you know

1213
00:44:42,208 --> 00:44:43,318
some crazy number like

1214
00:44:43,558 --> 00:44:45,088
we could pass in a four

1215
00:44:45,118 --> 00:44:47,488
and we can raise it to the power of six,

1216
00:44:47,788 --> 00:44:49,588
and so we should get like a pretty big number here

1217
00:44:50,008 --> 00:44:52,648
and you can see we get four thousand ninety six so

1218
00:44:53,098 --> 00:44:53,458
this

1219
00:44:53,489 --> 00:44:56,938
power function is really useful for taking numbers to specific

1220
00:44:56,969 --> 00:44:57,598
powers.

1221
00:44:57,988 --> 00:45:02,638
so in addition to using this power function we can also use another function which is called

1222
00:45:02,668 --> 00:45:03,628
max.

1223
00:45:03,898 --> 00:45:05,188
so I can say max.

1224
00:45:05,338 --> 00:45:08,248
and what this is gonna do is it's basically gonna return

1225
00:45:08,278 --> 00:45:11,128
the larger of the two numbers that we pass into it

1226
00:45:11,398 --> 00:45:12,748
so right now I'm giving this

1227
00:45:12,778 --> 00:45:14,338
a four and a six

1228
00:45:14,518 --> 00:45:16,828
and this should tell us which number is higher

1229
00:45:17,158 --> 00:45:20,458
so over here it's just pulling out six because that's the bigger number.

1230
00:45:20,728 --> 00:45:22,558
I cannot see is another function called

1231
00:45:22,588 --> 00:45:28,739
men and this is going to do the opposite so now instead of printing out the max number it's going to print out the smallest number.

1232
00:45:29,009 --> 00:45:31,739
and it's going to turn out for down here as you can see.

1233
00:45:32,039 --> 00:45:34,919
another cool function is called the round function

1234
00:45:34,949 --> 00:45:40,409
and this is going to allow us to round a number so it's just going to follow like standard rounding rules.

1235
00:45:40,709 --> 00:45:43,469
so if I said like three point to inside of here

1236
00:45:43,739 --> 00:45:44,999
now is going around it

1237
00:45:45,029 --> 00:45:47,099
down to just normal three

1238
00:45:47,129 --> 00:45:49,229
but if I said like three point seven.

1239
00:45:49,949 --> 00:45:54,150
it's going to round it up to four so that'll allow you to round a number.

1240
00:45:54,660 --> 00:45:58,500
so there's a few other functions that I want to show you guys but in order to

1241
00:45:58,530 --> 00:46:01,830
get access to them I'm actually going to have to do something called

1242
00:46:01,890 --> 00:46:02,640
importing

1243
00:46:03,180 --> 00:46:05,430
and in python we can actually

1244
00:46:05,460 --> 00:46:06,270
import

1245
00:46:06,360 --> 00:46:07,650
external code

1246
00:46:08,040 --> 00:46:10,890
into our files and so if I want to access these

1247
00:46:10,920 --> 00:46:11,610
specific

1248
00:46:11,640 --> 00:46:12,720
math functions.

1249
00:46:13,260 --> 00:46:15,601
I have to import something called python math

1250
00:46:15,631 --> 00:46:17,281
so I can just say from

1251
00:46:17,521 --> 00:46:18,990
up here math

1252
00:46:19,591 --> 00:46:20,431
import

1253
00:46:21,331 --> 00:46:24,450
and this star and basically what this is gonna do is it's going to

1254
00:46:24,690 --> 00:46:26,130
go out and it's going to grab

1255
00:46:26,190 --> 00:46:29,371
a bunch of different math functions that we can use so

1256
00:46:29,611 --> 00:46:33,961
I already showed you guys a few of the zipper math functions but there's actually a bunch more.

1257
00:46:34,322 --> 00:46:38,762
and in order to access them we're going to need to include this line of code inside of our file.

1258
00:46:39,062 --> 00:46:42,032
so once we have that now I can access a few other so

1259
00:46:42,062 --> 00:46:44,942
is another function which is called the floor method and it's just

1260
00:46:45,002 --> 00:46:46,082
f l o r

1261
00:46:46,472 --> 00:46:48,962
and what this will do is it'll basically just grab

1262
00:46:48,992 --> 00:46:49,532
the

1263
00:46:49,562 --> 00:46:53,252
lowest number so it's essentially just going to chop off this decimal point.

1264
00:46:53,762 --> 00:46:55,292
and you can see over here now

1265
00:46:55,322 --> 00:46:57,872
we get a three because we're using that floor function.

1266
00:46:58,232 --> 00:46:59,462
there's also another one called

1267
00:46:59,492 --> 00:47:00,302
seal.

1268
00:47:00,722 --> 00:47:04,382
and that's just going to do the exact opposite so that's just going around the number up

1269
00:47:04,412 --> 00:47:05,552
no matter what so

1270
00:47:05,612 --> 00:47:07,652
no matter what will always get for

1271
00:47:07,922 --> 00:47:10,022
which we have a three point whatever here

1272
00:47:10,322 --> 00:47:14,732
and there's another one which is called square root so it's just asking you our team

1273
00:47:15,062 --> 00:47:19,712
and essentially this is just going to return the square root of a number so I can say like

1274
00:47:19,742 --> 00:47:20,702
thirty six.

1275
00:47:20,972 --> 00:47:22,772
and now we should get six back.

1276
00:47:23,522 --> 00:47:24,242
so

1277
00:47:24,332 --> 00:47:26,552
those are also very interesting functions and

1278
00:47:26,912 --> 00:47:28,082
inside of this

1279
00:47:28,112 --> 00:47:34,202
math module so we would call this a module and you don't have to worry too much about what that is right now,

1280
00:47:34,532 --> 00:47:37,862
just know that when we put this line of code into our program

1281
00:47:37,892 --> 00:47:40,232
it gives us access to a lot more

1282
00:47:40,262 --> 00:47:41,012
math

1283
00:47:41,492 --> 00:47:42,332
function so though

1284
00:47:42,572 --> 00:47:45,842
it basically allows us to do a lot more things with math

1285
00:47:45,872 --> 00:47:46,982
inside of our program

1286
00:47:47,312 --> 00:47:49,653
and there's a bunch of different math functions

1287
00:47:49,863 --> 00:47:54,483
in python and if you why you can basically just go online and search for different math functions.

1288
00:47:54,783 --> 00:47:58,804
I showed you guys a few here and I would say the ones that we looked at here are

1289
00:47:59,074 --> 00:48:02,524
probably the most commonly used but there's a bunch more.

1290
00:48:02,764 --> 00:48:03,034
and

1291
00:48:03,124 --> 00:48:04,174
like I said you know there's

1292
00:48:04,204 --> 00:48:07,324
tons of documentation on all this stuff so you can just look up

1293
00:48:07,564 --> 00:48:09,004
your math functions in

1294
00:48:09,034 --> 00:48:12,814
python and there's going to be tons and tons like lists of these things

1295
00:48:13,114 --> 00:48:16,594
that you can use inside of your programs to perform different math

1296
00:48:16,624 --> 00:48:17,404
operations,

1297
00:48:17,524 --> 00:48:24,334
but for now that has been a little bit of by using numbers a little bit about doing it on certain math operations and using functions

1298
00:48:24,425 --> 00:48:25,625
with those numbers

1299
00:48:29,495 --> 00:48:31,715
in this tutorial I'm going to show you how to get

1300
00:48:31,745 --> 00:48:33,455
input from the user.

1301
00:48:33,725 --> 00:48:36,575
so we're basically going to allow a user to

1302
00:48:36,635 --> 00:48:39,305
input information into our program.

1303
00:48:39,605 --> 00:48:42,785
and I'm actually going to take the information that the user inputs.

1304
00:48:42,995 --> 00:48:43,895
I'm gonna store it

1305
00:48:43,925 --> 00:48:47,646
inside of a variable and then we're going to be able to do something with

1306
00:48:47,706 --> 00:48:48,786
that variable.

1307
00:48:49,266 --> 00:48:52,146
so I want to show you guys how we can actually go about getting

1308
00:48:52,206 --> 00:48:53,316
input from someone.

1309
00:48:53,586 --> 00:48:55,656
and down here in my python file.

1310
00:48:56,166 --> 00:48:59,826
all I have to do to get input from someone is I just have to type out

1311
00:48:59,886 --> 00:49:00,546
input

1312
00:49:01,026 --> 00:49:02,556
and then an open and closed

1313
00:49:02,586 --> 00:49:03,576
parentheses.

1314
00:49:03,936 --> 00:49:07,056
and what this is basically going to do is it's going to tell python like

1315
00:49:07,086 --> 00:49:08,315
hey we want to get

1316
00:49:08,406 --> 00:49:09,305
input from

1317
00:49:09,335 --> 00:49:10,745
a user in python will

1318
00:49:10,955 --> 00:49:12,485
allow the user to

1319
00:49:12,515 --> 00:49:14,255
type in some information

1320
00:49:14,795 --> 00:49:17,585
and inside of these parentheses we can actually type

1321
00:49:17,615 --> 00:49:18,485
a prompt

1322
00:49:18,935 --> 00:49:22,175
and so generally when we want the user to enter in some information

1323
00:49:22,205 --> 00:49:23,915
we want to tell them what we want them

1324
00:49:23,945 --> 00:49:24,605
to enter.

1325
00:49:24,965 --> 00:49:27,545
and that's what we can put inside of here so I'm just going to say.

1326
00:49:28,115 --> 00:49:29,225
enter your

1327
00:49:29,255 --> 00:49:29,915
name,

1328
00:49:30,875 --> 00:49:33,966
so we're actually going to create a little python app,

1329
00:49:34,296 --> 00:49:36,756
which is going to allow the user to enter in their name

1330
00:49:37,056 --> 00:49:40,806
and then will store the name inside of a variable and then we'll basically just

1331
00:49:40,836 --> 00:49:43,327
say hi to the user so we'll say like high

1332
00:49:43,597 --> 00:49:45,697
and then whatever the name they entered was

1333
00:49:46,447 --> 00:49:49,117
so what I want to do is I actually wanna store

1334
00:49:49,147 --> 00:49:52,057
whatever the user and put it into our program

1335
00:49:52,477 --> 00:49:54,007
inside of a variable.

1336
00:49:54,217 --> 00:49:58,927
so I can actually go over here and I can create a variable I could just call it name

1337
00:49:59,347 --> 00:50:01,147
and I could set this variable

1338
00:50:01,207 --> 00:50:02,317
equal to

1339
00:50:02,737 --> 00:50:03,307
input.

1340
00:50:03,727 --> 00:50:07,957
so what I'm doing now is I'm taking the value that the user inputs

1341
00:50:08,437 --> 00:50:08,827
and I'm

1342
00:50:09,037 --> 00:50:10,537
storing it inside of this

1343
00:50:10,567 --> 00:50:12,277
variable container called

1344
00:50:12,337 --> 00:50:12,967
name

1345
00:50:13,447 --> 00:50:14,407
and so now

1346
00:50:14,827 --> 00:50:17,467
I have access to whatever they entered it.

1347
00:50:17,797 --> 00:50:19,537
so what we can do is we can say

1348
00:50:19,567 --> 00:50:20,287
print

1349
00:50:21,007 --> 00:50:22,027
and inside of the

1350
00:50:22,057 --> 00:50:24,127
parentheses I can just print out

1351
00:50:24,577 --> 00:50:25,207
hello

1352
00:50:26,257 --> 00:50:28,028
and then I'm just going to add on to this

1353
00:50:28,177 --> 00:50:28,778
name

1354
00:50:29,588 --> 00:50:31,688
and actually want to put an exclamation point.

1355
00:50:32,318 --> 00:50:35,498
so essentially we're getting a name from the user.

1356
00:50:35,648 --> 00:50:37,868
restoring it inside of the named variable

1357
00:50:38,018 --> 00:50:38,888
and I'm printing it

1358
00:50:38,918 --> 00:50:40,508
out onto the screen.

1359
00:50:40,778 --> 00:50:42,458
so I'm gonna go ahead and play this ?

1360
00:50:42,848 --> 00:50:45,698
and when we run the program you'll notice down here

1361
00:50:45,728 --> 00:50:47,978
python is giving us this little problem

1362
00:50:48,008 --> 00:50:48,668
so it saying

1363
00:50:48,698 --> 00:50:49,448
enter your name.

1364
00:50:49,838 --> 00:50:50,198
now

1365
00:50:50,229 --> 00:50:54,099
in here I can actually type in of values so I could type in might.

1366
00:50:54,999 --> 00:50:56,528
and then I can just hit enter

1367
00:50:57,218 --> 00:51:01,448
and pythons going to go ahead and store this value inside of that variable

1368
00:51:01,779 --> 00:51:03,159
and then it's going to print out

1369
00:51:03,219 --> 00:51:03,879
hello

1370
00:51:03,909 --> 00:51:04,449
mike.

1371
00:51:04,539 --> 00:51:05,979
and so this is kind of cool and

1372
00:51:06,009 --> 00:51:07,989
actually what we could do is we could

1373
00:51:08,199 --> 00:51:11,919
prompt the user to enter in more than one piece of information.

1374
00:51:12,549 --> 00:51:13,839
so I can actually

1375
00:51:13,869 --> 00:51:15,429
copy this line of code.

1376
00:51:16,119 --> 00:51:16,599
and I'm an

1377
00:51:16,629 --> 00:51:17,889
pasted below here

1378
00:51:18,069 --> 00:51:21,310
and why don't we have the user enter in another variable.

1379
00:51:21,520 --> 00:51:23,679
so we could have them enter in for example their

1380
00:51:23,709 --> 00:51:24,339
age.

1381
00:51:24,699 --> 00:51:26,859
and over here we just want to say enter your

1382
00:51:26,949 --> 00:51:27,550
age.

1383
00:51:27,850 --> 00:51:28,540
so now

1384
00:51:28,570 --> 00:51:31,750
we're able to get two pieces of information from the user.

1385
00:51:32,020 --> 00:51:33,640
and I could say hello name.

1386
00:51:34,030 --> 00:51:35,020
and then I can say

1387
00:51:35,830 --> 00:51:36,820
you are

1388
00:51:37,240 --> 00:51:38,410
and I'll print out their

1389
00:51:38,440 --> 00:51:38,860
age

1390
00:51:38,890 --> 00:51:40,030
so I'm going to print

1391
00:51:40,390 --> 00:51:40,930
age.

1392
00:51:41,170 --> 00:51:45,521
so now I'm basically able to get both of these pieces of information

1393
00:51:45,551 --> 00:51:47,831
from the user I can get their name

1394
00:51:48,161 --> 00:51:50,981
and I can get their age so when we run this program.

1395
00:51:52,421 --> 00:51:55,901
I can type in both of those pieces of information so as they enter your name.

1396
00:51:56,231 --> 00:51:56,801
so

1397
00:51:56,831 --> 00:51:57,371
we could just

1398
00:51:57,431 --> 00:51:58,961
make up a name like john

1399
00:51:59,261 --> 00:52:02,292
and then enter the age that say john is twenty five

1400
00:52:02,802 --> 00:52:05,532
and now is going to say hello john you are twenty five.

1401
00:52:05,922 --> 00:52:09,102
so the program is able to get input from the user and then it's

1402
00:52:09,132 --> 00:52:11,292
able to use that information

1403
00:52:11,502 --> 00:52:13,572
in order to say hi to the user and

1404
00:52:13,602 --> 00:52:15,102
tell them how old they are,

1405
00:52:15,432 --> 00:52:15,882
so

1406
00:52:15,942 --> 00:52:20,922
getting input from the user is a great way to make your programs more interactive and

1407
00:52:21,222 --> 00:52:27,012
here we're just scratching the surface right word just basically getting to know a piece of information from the user but

1408
00:52:27,312 --> 00:52:29,143
you can use these inputs to do

1409
00:52:29,203 --> 00:52:32,263
awesome things in python and as we go through this course.

1410
00:52:32,503 --> 00:52:33,193
you're going to see some

1411
00:52:33,223 --> 00:52:34,903
really cool things that we can do

1412
00:52:34,963 --> 00:52:36,283
with these inputs

1413
00:52:40,124 --> 00:52:41,984
in this tutorial I'm going to show you how to build

1414
00:52:42,014 --> 00:52:45,254
a very basic calculator in python.

1415
00:52:45,584 --> 00:52:49,454
we're basically going to build a calculator where we'll get to numbers from a user,

1416
00:52:49,664 --> 00:52:50,174
and then we'll

1417
00:52:50,204 --> 00:52:53,714
add those numbers together and print the answer out onto the screen.

1418
00:52:54,044 --> 00:52:58,664
so this will give us some practice in getting input from users and we'll also talk about getting

1419
00:52:58,694 --> 00:53:01,034
numbers from users as opposed to just

1420
00:53:01,094 --> 00:53:01,904
strings.

1421
00:53:02,204 --> 00:53:03,434
so I'm really excited to

1422
00:53:03,674 --> 00:53:04,964
get started on this calculator.

1423
00:53:05,474 --> 00:53:07,005
the first thing we want to do is

1424
00:53:07,035 --> 00:53:07,665
create

1425
00:53:07,695 --> 00:53:09,045
two variables and

1426
00:53:09,105 --> 00:53:11,685
inside of those variables we want to store

1427
00:53:11,745 --> 00:53:14,745
the two numbers that the user wants to add together

1428
00:53:15,195 --> 00:53:16,005
so down here,

1429
00:53:16,095 --> 00:53:17,086
I'm just going to say,

1430
00:53:18,046 --> 00:53:18,855
number one,

1431
00:53:19,125 --> 00:53:20,776
and that's what we'll call our first variable

1432
00:53:21,076 --> 00:53:21,316
is

1433
00:53:21,346 --> 00:53:22,216
equal to.

1434
00:53:22,456 --> 00:53:25,396
and now I need to get input from the user so I'm going to say.

1435
00:53:25,456 --> 00:53:26,146
input

1436
00:53:26,566 --> 00:53:28,006
and inside these parentheses

1437
00:53:28,036 --> 00:53:28,846
I'm going to say.

1438
00:53:28,996 --> 00:53:30,826
enter a number,

1439
00:53:33,496 --> 00:53:36,046
and now I basically want to do the same exact

1440
00:53:36,076 --> 00:53:36,736
thing

1441
00:53:36,766 --> 00:53:37,696
but for

1442
00:53:37,726 --> 00:53:38,506
the second number,

1443
00:53:38,956 --> 00:53:40,606
so we'll piece this guy down here,

1444
00:53:41,296 --> 00:53:43,456
and I'm just going to say gnome

1445
00:53:43,486 --> 00:53:44,086
two

1446
00:53:44,686 --> 00:53:45,796
and then we'll just say

1447
00:53:45,976 --> 00:53:47,356
enter another number.

1448
00:53:47,927 --> 00:53:50,207
so now we're able to store the user's input

1449
00:53:50,447 --> 00:53:51,377
inside of these

1450
00:53:51,407 --> 00:53:51,887
two

1451
00:53:51,917 --> 00:53:52,637
variables.

1452
00:53:52,817 --> 00:53:56,507
so now all I want to do is just print out the results so

1453
00:53:56,867 --> 00:54:01,308
I'm actually going to create a variable called result somebody's going to say a result

1454
00:54:01,548 --> 00:54:02,538
is equal to

1455
00:54:02,568 --> 00:54:06,168
and basically we just want to add these two numbers together something as a number one

1456
00:54:06,468 --> 00:54:06,948
plus

1457
00:54:06,978 --> 00:54:07,518
numb

1458
00:54:07,548 --> 00:54:07,998
too.

1459
00:54:08,988 --> 00:54:12,318
and now all we have to do is print out the results I'm just going to print

1460
00:54:12,918 --> 00:54:13,519
result

1461
00:54:14,329 --> 00:54:14,899
so

1462
00:54:14,929 --> 00:54:18,259
we basically have our entire program written out here

1463
00:54:18,469 --> 00:54:22,878
and this will allow us to enter in two numbers and then we'll add them together and print out the answer

1464
00:54:24,948 --> 00:54:25,998
so I could play.

1465
00:54:26,418 --> 00:54:29,268
and down here we can enter our number,

1466
00:54:29,328 --> 00:54:31,368
so I'm gonna enter the first number we'll say five,

1467
00:54:32,088 --> 00:54:35,118
and I'm going to enter my second number so let's say

1468
00:54:35,148 --> 00:54:36,828
eight point zero

1469
00:54:37,338 --> 00:54:38,508
or else a point

1470
00:54:38,718 --> 00:54:39,258
three

1471
00:54:40,278 --> 00:54:41,958
it's now should print out the answer,

1472
00:54:42,228 --> 00:54:42,888
but

1473
00:54:43,038 --> 00:54:44,628
if you look over here.

1474
00:54:45,288 --> 00:54:49,188
that's not quite the answer we were looking for at five plus

1475
00:54:49,218 --> 00:54:49,698
eight point

1476
00:54:49,728 --> 00:54:52,968
three is definitely not fifty eight points three

1477
00:54:53,328 --> 00:54:54,558
and here's what happened

1478
00:54:55,218 --> 00:54:57,648
when we get input from a user

1479
00:54:57,708 --> 00:54:59,178
by default.

1480
00:54:59,808 --> 00:55:01,518
python is just going to convert

1481
00:55:01,548 --> 00:55:02,508
it into a string,

1482
00:55:02,718 --> 00:55:04,458
so it doesn't matter what we put

1483
00:55:04,488 --> 00:55:06,408
down their when we're entering the numbers

1484
00:55:06,738 --> 00:55:08,328
python's always is going to be like.

1485
00:55:08,388 --> 00:55:08,808
ok

1486
00:55:08,838 --> 00:55:09,829
this is a string

1487
00:55:09,859 --> 00:55:10,579
that's it

1488
00:55:10,969 --> 00:55:12,019
sounds good right ?

1489
00:55:12,198 --> 00:55:13,879
it's just going to make it a string

1490
00:55:14,179 --> 00:55:16,578
in order for us to make these number one and number

1491
00:55:16,608 --> 00:55:18,018
two variables numbers,

1492
00:55:18,168 --> 00:55:22,368
we're actually going to have to convert the strings that we get from the user

1493
00:55:22,758 --> 00:55:24,018
into numbers,

1494
00:55:24,108 --> 00:55:24,618
and so

1495
00:55:24,858 --> 00:55:26,988
the way that we can do that is by

1496
00:55:27,018 --> 00:55:28,548
basically just coming over here

1497
00:55:28,818 --> 00:55:30,918
and when we add the two numbers together

1498
00:55:30,948 --> 00:55:33,618
I can use a special python function

1499
00:55:33,918 --> 00:55:35,418
in order to convert those

1500
00:55:35,448 --> 00:55:36,378
strings

1501
00:55:36,678 --> 00:55:37,698
into numbers.

1502
00:55:38,118 --> 00:55:39,888
and there's actually two

1503
00:55:39,918 --> 00:55:41,988
python functions that we could use for this.

1504
00:55:42,228 --> 00:55:43,219
the first is called

1505
00:55:43,249 --> 00:55:43,638
int

1506
00:55:43,668 --> 00:55:45,559
so I could say I auntie.

1507
00:55:45,889 --> 00:55:46,459
I can make an

1508
00:55:46,489 --> 00:55:49,489
open parentheses and I can make a close parentheses

1509
00:55:49,729 --> 00:55:53,988
and basically what this is gonna do is it's going to convert whatever is inside of these

1510
00:55:54,018 --> 00:55:55,398
open or close parentheses

1511
00:55:55,668 --> 00:55:56,148
into an

1512
00:55:56,178 --> 00:55:56,838
integer

1513
00:55:56,868 --> 00:55:57,469
number,

1514
00:55:57,918 --> 00:55:58,248
and an

1515
00:55:58,278 --> 00:56:04,219
integer number is basically a whole number so it's like one two three four or five so it's a,

1516
00:56:04,458 --> 00:56:07,489
it's a whole number another word that can't have a decimal point,

1517
00:56:08,749 --> 00:56:10,458
so what I could do is I could say

1518
00:56:10,908 --> 00:56:11,838
I n t,

1519
00:56:12,318 --> 00:56:13,308
and I could put these

1520
00:56:13,338 --> 00:56:14,148
inside of

1521
00:56:14,328 --> 00:56:15,168
parentheses.

1522
00:56:15,378 --> 00:56:19,788
and now what this is gonna do is it's going to convert both of these numbers into

1523
00:56:19,848 --> 00:56:21,048
integers in other words

1524
00:56:21,408 --> 00:56:22,248
into

1525
00:56:22,338 --> 00:56:24,528
whole numbers that don't have decimals,

1526
00:56:24,708 --> 00:56:28,698
and it's going to add them together and will print out the result so why don't we do that

1527
00:56:28,759 --> 00:56:30,528
we'll just see if this works I'm gonna

1528
00:56:30,648 --> 00:56:31,578
click the play button

1529
00:56:31,998 --> 00:56:35,688
and down here we'll enter our first number sums can enter into four

1530
00:56:36,078 --> 00:56:37,549
and then I'll answer in a five

1531
00:56:37,789 --> 00:56:41,358
and now you can see it's printing out the correct answer four plus

1532
00:56:41,388 --> 00:56:42,018
five

1533
00:56:42,198 --> 00:56:45,168
and so that's essentially our basic calculator.

1534
00:56:45,228 --> 00:56:46,488
but we do have one

1535
00:56:46,518 --> 00:56:50,719
problem with this calculator salmon run it again and I'll show you guys with that problem is

1536
00:56:50,749 --> 00:56:52,159
if I wanted to add in

1537
00:56:52,189 --> 00:56:57,169
a decimal number so we'll add four point three and five point five.

1538
00:56:58,099 --> 00:56:59,929
you'll see that we're getting this error.

1539
00:57:00,169 --> 00:57:02,869
and that's because I'm using this

1540
00:57:02,959 --> 00:57:03,320
ain't

1541
00:57:03,350 --> 00:57:05,030
function of here and this

1542
00:57:05,090 --> 00:57:08,029
int function is looking for a whole number.

1543
00:57:08,299 --> 00:57:08,659
so if

1544
00:57:08,689 --> 00:57:11,900
I put decimal numbers inside of there it's going to break the programs.

1545
00:57:12,710 --> 00:57:14,510
there's another function we can use

1546
00:57:14,570 --> 00:57:15,200
instead of an

1547
00:57:15,230 --> 00:57:16,969
n we can say float

1548
00:57:17,240 --> 00:57:18,020
and a float

1549
00:57:18,050 --> 00:57:21,709
is basically just a number that has decimal so it's a decimal number

1550
00:57:22,129 --> 00:57:25,339
so I can convert both of these guys into floats

1551
00:57:26,119 --> 00:57:29,449
and now I'll be able to use decimal number so I can click play.

1552
00:57:29,959 --> 00:57:33,079
and I can just enter into number so I could say like four

1553
00:57:33,559 --> 00:57:35,899
and I could also say like five point five.

1554
00:57:36,139 --> 00:57:38,089
and now it's going to be able to add

1555
00:57:38,119 --> 00:57:39,259
both of those numbers.

1556
00:57:39,619 --> 00:57:41,060
even if one of them is a decimal

1557
00:57:41,090 --> 00:57:44,299
and that's the beauty of using that little float function so

1558
00:57:44,599 --> 00:57:49,309
in certain circumstances you might want the user to only be able to enter into an integer

1559
00:57:49,579 --> 00:57:50,569
to a whole number.

1560
00:57:50,719 --> 00:57:52,999
but in a lot of cases like in this calculator.

1561
00:57:53,059 --> 00:57:56,870
we want them to be able to answer any number that they want so we're going to use this flow

1562
00:57:57,200 --> 00:57:57,710
function.

1563
00:57:58,190 --> 00:57:58,580
so

1564
00:57:58,610 --> 00:58:02,750
I'm just going to recap what we did one more time we created two variables number one and number two

1565
00:58:03,410 --> 00:58:08,240
and we basically stored the two numbers that the user's implanted into those variables,

1566
00:58:08,660 --> 00:58:11,210
then we converted them into numbers

1567
00:58:11,571 --> 00:58:12,141
and

1568
00:58:12,171 --> 00:58:12,651
weed

1569
00:58:12,681 --> 00:58:14,990
out of them together and we printed out the results so

1570
00:58:15,051 --> 00:58:17,301
this is a pretty cool calculator, i'm happy with it.

1571
00:58:17,601 --> 00:58:18,951
hopefully you guys learned something.

1572
00:58:19,161 --> 00:58:26,272
and as we go forward in this python course you're going to learn all sorts of ways that we can make this calculator more complex

1573
00:58:30,082 --> 00:58:32,452
in this tutorial I wanna show you guys how to build a

1574
00:58:32,482 --> 00:58:34,372
mad libs game in

1575
00:58:34,402 --> 00:58:35,062
python,

1576
00:58:35,482 --> 00:58:41,632
so a mad libs game is basically just a game where you can enter in a bunch of random words so like

1577
00:58:41,752 --> 00:58:42,112
you know

1578
00:58:42,142 --> 00:58:43,342
verbs nouns

1579
00:58:43,402 --> 00:58:44,302
names

1580
00:58:44,422 --> 00:58:45,112
colors

1581
00:58:45,532 --> 00:58:46,042
and

1582
00:58:46,132 --> 00:58:48,022
you basically take all of those words and

1583
00:58:48,052 --> 00:58:50,662
put them into a story randomly so

1584
00:58:51,412 --> 00:58:52,282
over here I had

1585
00:58:52,312 --> 00:58:53,692
my web browser I just have

1586
00:58:53,752 --> 00:58:55,912
an example of a mad libs so you know

1587
00:58:55,942 --> 00:59:00,353
down here were basically just taking random words like an adjective or a noun or a pronoun

1588
00:59:00,743 --> 00:59:02,153
and entering them in

1589
00:59:02,213 --> 00:59:06,083
sort of a story so like you read through the story than like some random word pops up in

1590
00:59:06,353 --> 00:59:08,423
mad libs can be pretty fun and I'm sure 

