WEBVTT

00:00:00.030 --> 00:00:01.829
alright welcome back in this video

00:00:01.829 --> 00:00:03.270
you'll learn about something that is a

00:00:03.270 --> 00:00:05.220
fundamental aspect of just about every

00:00:05.220 --> 00:00:08.130
programming language variables let's

00:00:08.130 --> 00:00:09.570
dive in and look at a program that has a

00:00:09.570 --> 00:00:11.670
variable in it in a minute we'll take

00:00:11.670 --> 00:00:12.870
some time to go over exactly what a

00:00:12.870 --> 00:00:14.610
variable is and what it does the

00:00:14.610 --> 00:00:15.960
variable in this program is called

00:00:15.960 --> 00:00:18.390
greeting it has a value which is hello

00:00:18.390 --> 00:00:20.820
world this means that printing greeting

00:00:20.820 --> 00:00:22.650
is basically the same as printing hello

00:00:22.650 --> 00:00:23.160
world

00:00:23.160 --> 00:00:25.170
here's another program with a variable

00:00:25.170 --> 00:00:27.449
the variable is called my number and its

00:00:27.449 --> 00:00:30.630
value with the number 50 okay so what is

00:00:30.630 --> 00:00:32.489
a variable a variable is something that

00:00:32.489 --> 00:00:34.380
stores information in a program so that

00:00:34.380 --> 00:00:36.480
it can be used later that information

00:00:36.480 --> 00:00:38.190
can be something like hello world or the

00:00:38.190 --> 00:00:40.920
number 50 more specifically a variable

00:00:40.920 --> 00:00:43.500
has three things a name a type and a

00:00:43.500 --> 00:00:46.469
value so let's look at the two variables

00:00:46.469 --> 00:00:48.149
that we just saw and spell out each of

00:00:48.149 --> 00:00:50.039
these three characteristics in the case

00:00:50.039 --> 00:00:51.690
of the variable greeting the name of the

00:00:51.690 --> 00:00:54.030
variable is greeting the type of the

00:00:54.030 --> 00:00:55.860
variable is ster which I'll explain in a

00:00:55.860 --> 00:00:58.109
second and the value is hello world in

00:00:58.109 --> 00:00:58.559
quotes

00:00:58.559 --> 00:01:00.090
note that when you print the variable

00:01:00.090 --> 00:01:02.539
greeting you don't put quotes around it

00:01:02.539 --> 00:01:05.640
then we saw a variable whose name was my

00:01:05.640 --> 00:01:08.010
number whose type was int which I'll

00:01:08.010 --> 00:01:10.020
also explain in a second and whose value

00:01:10.020 --> 00:01:13.110
was 50 okay so what did these types mean

00:01:13.110 --> 00:01:16.229
stur is short for string a variable

00:01:16.229 --> 00:01:18.210
whose type is ster contains text or a

00:01:18.210 --> 00:01:20.430
sequence of zero or more characters and

00:01:20.430 --> 00:01:22.470
these characters can be letters numbers

00:01:22.470 --> 00:01:24.659
punctuation spaces whatever you can type

00:01:24.659 --> 00:01:26.670
on your keyboard so hello world is an

00:01:26.670 --> 00:01:30.299
example abc123 is an example or a string

00:01:30.299 --> 00:01:32.549
can actually have zero characters okay

00:01:32.549 --> 00:01:34.320
quick digression strings can also be

00:01:34.320 --> 00:01:36.329
surrounded by single quotes in Python

00:01:36.329 --> 00:01:37.920
however in this course we will use

00:01:37.920 --> 00:01:40.439
double quotes now let's look at the type

00:01:40.439 --> 00:01:43.290
int int is short for integer and a

00:01:43.290 --> 00:01:45.240
variable whose type is int contains a

00:01:45.240 --> 00:01:48.030
number and that number can be positive

00:01:48.030 --> 00:01:51.060
negative or zero however it cannot have

00:01:51.060 --> 00:01:53.820
a decimal component so negative 50 0 and

00:01:53.820 --> 00:01:56.369
5 are all examples of integers another

00:01:56.369 --> 00:01:57.869
type that we haven't seen yet but we

00:01:57.869 --> 00:02:00.750
will in future lessons is float float is

00:02:00.750 --> 00:02:02.640
short for floating point number and this

00:02:02.640 --> 00:02:04.380
is basically like an integer except it

00:02:04.380 --> 00:02:06.450
does have a decimal component so

00:02:06.450 --> 00:02:08.940
negative three point two zero point zero

00:02:08.940 --> 00:02:11.730
or four point five six five two are all

00:02:11.730 --> 00:02:12.569
examples of

00:02:12.569 --> 00:02:14.909
note that the decimal component can be

00:02:14.909 --> 00:02:17.879
zero so zero point zero is in fact equal

00:02:17.879 --> 00:02:20.909
to the integer zero you can create a new

00:02:20.909 --> 00:02:23.040
variable or update an existing variable

00:02:23.040 --> 00:02:24.540
in Python using what's called an

00:02:24.540 --> 00:02:26.549
assignment statement this statement has

00:02:26.549 --> 00:02:29.069
three parts on the left you have the

00:02:29.069 --> 00:02:31.049
name of the variable on the right you

00:02:31.049 --> 00:02:32.670
have the value that you want to give to

00:02:32.670 --> 00:02:34.590
that variable and in the middle you just

00:02:34.590 --> 00:02:37.970
have a single equal sign
