Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,500 --> 00:00:03,400
alright everybody we are moving on to variables
2
00:00:03,400 --> 00:00:06,200
a variable is a container for a value
3
00:00:06,200 --> 00:00:08,700
there's four different data types we'll discuss
4
00:00:08,933 --> 00:00:11,966
strings integers floats and booleans
5
00:00:12,200 --> 00:00:13,800
yes I know that's a silly name
6
00:00:14,533 --> 00:00:18,300
variable behaves as if it was the value it contains
7
00:00:18,300 --> 00:00:20,500
each variable should have a unique name
8
00:00:20,900 --> 00:00:23,533
let's say we have a variable of first name
9
00:00:24,133 --> 00:00:25,333
to assign a variable
10
00:00:25,333 --> 00:00:28,066
you use the assignment operator of equals
11
00:00:28,366 --> 00:00:31,566
for text a string is a series of text
12
00:00:31,733 --> 00:00:34,566
this can be double quotes or single quotes
13
00:00:34,766 --> 00:00:37,100
my own preference is double quotes
14
00:00:37,700 --> 00:00:39,200
why don't you type in your first name
15
00:00:40,333 --> 00:00:42,133
this variable a first name
16
00:00:42,300 --> 00:00:44,600
will behave as if it was this value
17
00:00:44,866 --> 00:00:46,566
this series of characters
18
00:00:47,133 --> 00:00:50,066
so to demonstrate this I'm going to print
19
00:00:50,366 --> 00:00:52,466
my first name variable
20
00:00:53,666 --> 00:00:56,700
so place it within a print statement without quotes
21
00:00:57,166 --> 00:00:58,866
that will print your first name
22
00:00:59,766 --> 00:01:01,900
now you don't want this within quotes
23
00:01:03,766 --> 00:01:05,733
because then you're literally printing
24
00:01:05,733 --> 00:01:07,100
the word first name
25
00:01:09,133 --> 00:01:12,133
you could use your variable along with some text
26
00:01:12,133 --> 00:01:14,366
by using what is called an F string
27
00:01:14,900 --> 00:01:17,166
that's the easiest way to display a variable
28
00:01:17,300 --> 00:01:18,533
so you type F
29
00:01:18,800 --> 00:01:20,000
menasetic quotes
30
00:01:20,466 --> 00:01:21,900
the F means format
31
00:01:22,566 --> 00:01:24,700
so let's say the word hello
32
00:01:25,133 --> 00:01:26,733
then we will add our variable
33
00:01:27,066 --> 00:01:29,900
we will insert our variable into this text
34
00:01:29,900 --> 00:01:31,266
when using an F string
35
00:01:31,466 --> 00:01:33,800
to do that you need a set of curly braces
36
00:01:34,266 --> 00:01:35,900
then insert your variable
37
00:01:36,800 --> 00:01:39,200
so the result is hello
38
00:01:39,466 --> 00:01:42,300
whatever your first name is in my case bro
39
00:01:43,000 --> 00:01:44,400
let's create another variable
40
00:01:45,700 --> 00:01:48,400
let's say we have a variable of food
41
00:01:48,933 --> 00:01:51,566
food equals think of your favorite food
42
00:01:52,166 --> 00:01:53,966
for me I will type pizza
43
00:01:55,500 --> 00:01:56,866
let's print the following
44
00:01:58,266 --> 00:02:01,333
you like add a placeholder
45
00:02:01,333 --> 00:02:02,966
again I'm using an F string
46
00:02:04,200 --> 00:02:05,800
our variable of food
47
00:02:06,533 --> 00:02:08,600
hello bro you like pizza
48
00:02:10,166 --> 00:02:11,700
let's create an email
49
00:02:12,700 --> 00:02:14,733
use your own email or makeup 1
50
00:02:14,866 --> 00:02:16,800
let's say my email is bro
51
00:02:17,133 --> 00:02:20,100
onetwothreeatfake.com
52
00:02:22,866 --> 00:02:24,566
then let's print our email
53
00:02:26,366 --> 00:02:30,400
your email is at a placeholder
54
00:02:30,866 --> 00:02:32,800
display our email variable
55
00:02:34,333 --> 00:02:37,900
your email is bro 1 2 3 at fake com
56
00:02:39,733 --> 00:02:41,333
so these are strings
57
00:02:41,866 --> 00:02:45,100
I'm going to add a comment that these are strings
58
00:02:45,600 --> 00:02:48,200
a string is a series of characters
59
00:02:48,366 --> 00:02:49,766
they can include numbers
60
00:02:49,766 --> 00:02:51,600
but we treat them as characters
61
00:02:52,466 --> 00:02:53,800
now we have integers
62
00:02:54,600 --> 00:02:56,466
an integer is a whole number
63
00:02:57,000 --> 00:02:58,366
an example of this could
64
00:02:58,900 --> 00:02:59,900
somebody's age
65
00:02:59,900 --> 00:03:00,900
how old are they
66
00:03:01,300 --> 00:03:03,333
according to my YouTube statistics
67
00:03:03,333 --> 00:03:06,200
many of you are between the ages of 18 through 24
68
00:03:06,400 --> 00:03:08,066
let's say that I'm 25
69
00:03:08,933 --> 00:03:10,000
let me zoom in a little
70
00:03:10,333 --> 00:03:13,333
your integer should not be within quotes
71
00:03:13,900 --> 00:03:16,066
because it would be a string then technically
72
00:03:16,866 --> 00:03:18,900
if I would like to work with this variable
73
00:03:19,600 --> 00:03:21,166
again I'll use enough string
74
00:03:21,566 --> 00:03:23,300
let's say you are
75
00:03:23,666 --> 00:03:24,866
add a placeholder
76
00:03:25,366 --> 00:03:26,933
display our age variable
77
00:03:28,333 --> 00:03:29,700
years old
78
00:03:31,200 --> 00:03:33,133
you are 25 years old
79
00:03:34,600 --> 00:03:37,600
another example of an integer could be a quantity
80
00:03:39,166 --> 00:03:41,366
you are buying a certain amount of something
81
00:03:41,933 --> 00:03:44,133
maybe I am buying 3 items
82
00:03:44,666 --> 00:03:46,200
I wouldn't have half an item
83
00:03:46,533 --> 00:03:48,333
this would be a float technically
84
00:03:48,333 --> 00:03:49,666
rather than an integer
85
00:03:50,100 --> 00:03:51,766
we are buying 3 of something
86
00:03:52,900 --> 00:03:54,800
so let's print the following
87
00:03:55,733 --> 00:03:58,400
you are buying
88
00:03:59,133 --> 00:04:00,400
at a placeholder
89
00:04:00,900 --> 00:04:02,500
display our quantity
90
00:04:03,666 --> 00:04:04,566
items
91
00:04:05,933 --> 00:04:07,566
you are 25 years old
92
00:04:08,133 --> 00:04:10,133
you are buying 3 items
93
00:04:11,500 --> 00:04:13,500
another example of an integer could be
94
00:04:13,666 --> 00:04:14,866
an amount of people
95
00:04:15,533 --> 00:04:18,500
let's say number of students
96
00:04:18,600 --> 00:04:19,866
like a classroom
97
00:04:20,566 --> 00:04:23,066
there are 30 students in our class
98
00:04:24,100 --> 00:04:25,400
then we will print
99
00:04:26,900 --> 00:04:30,266
your class has at a placeholder
100
00:04:31,133 --> 00:04:35,466
students we will display the number of students
101
00:04:35,600 --> 00:04:37,166
number of students
102
00:04:38,300 --> 00:04:40,500
your class has 30 students
103
00:04:42,466 --> 00:04:43,666
those are integers
104
00:04:43,766 --> 00:04:45,066
their whole numbers
105
00:04:45,066 --> 00:04:47,566
and again make sure they're not within quotes
106
00:04:47,733 --> 00:04:50,133
because then technically they would be a string
107
00:04:51,200 --> 00:04:54,100
integers we can use in arithmetic expressions
108
00:04:54,133 --> 00:04:56,100
if they were strings we couldn't
109
00:04:57,700 --> 00:04:59,066
then we have floats
110
00:04:59,066 --> 00:05:00,800
float means floating point number
111
00:05:03,200 --> 00:05:06,266
a float is a number but it contains a decimal portion
112
00:05:06,533 --> 00:05:08,566
an example would be a price
113
00:05:08,566 --> 00:05:11,566
what is the price of something 1099
114
00:05:12,300 --> 00:05:13,666
let's print our price
115
00:05:13,900 --> 00:05:15,733
print I'll use an F string
116
00:05:16,366 --> 00:05:19,533
the price is at a placeholder
117
00:05:19,600 --> 00:05:20,900
display our price
118
00:05:22,466 --> 00:05:24,333
the price is 10 99
119
00:05:25,066 --> 00:05:27,966
let's precede our placeholder with a unit of currency
120
00:05:27,966 --> 00:05:29,300
I'll pick American dollars
121
00:05:29,300 --> 00:05:31,333
but feel free to pick something else
122
00:05:32,166 --> 00:05:34,733
the price is 10 dollars and 99 cents
123
00:05:35,200 --> 00:05:37,566
so floats contain a decimal portion
124
00:05:38,100 --> 00:05:40,866
what about a grade point average GPA
125
00:05:42,000 --> 00:05:45,900
let's say my GPA is 3.2
126
00:05:48,133 --> 00:05:49,500
then I will print
127
00:05:50,133 --> 00:05:52,366
your GPA is
128
00:05:55,333 --> 00:05:56,966
display our GPA
129
00:05:58,900 --> 00:06:01,133
your GPA is 3.2
130
00:06:02,333 --> 00:06:03,700
what about a distance
131
00:06:04,266 --> 00:06:06,500
a distance can contain a decimal portion
132
00:06:07,200 --> 00:06:10,200
5.5 km maybe
133
00:06:12,366 --> 00:06:13,766
then I will print
134
00:06:14,533 --> 00:06:17,666
you ran at a placeholder
135
00:06:17,733 --> 00:06:19,200
display our distance
136
00:06:19,533 --> 00:06:21,566
then I'll add km4km
137
00:06:22,100 --> 00:06:25,500
or you could add mi for miles but I'll stick with km
138
00:06:27,066 --> 00:06:29,600
you ran 5.5km
139
00:06:31,266 --> 00:06:33,133
k then we have booleans
140
00:06:33,200 --> 00:06:36,366
a boolean is either true or false
141
00:06:39,700 --> 00:06:41,100
let's say we are a student
142
00:06:41,533 --> 00:06:44,400
is student equals
143
00:06:44,666 --> 00:06:47,533
if we are a student we could say that this is true
144
00:06:48,166 --> 00:06:49,866
true starts with a capital T
145
00:06:50,366 --> 00:06:53,166
if we weren't a student let's say we graduate
146
00:06:53,800 --> 00:06:56,266
we could say that this is false
147
00:06:56,266 --> 00:06:58,166
again the first letter is capital
148
00:06:58,566 --> 00:07:01,966
booleans only have two options true or false
149
00:07:02,066 --> 00:07:03,900
so let's say that I am a student
150
00:07:05,000 --> 00:07:06,400
then I will print
151
00:07:07,466 --> 00:07:09,666
are you a student
152
00:07:11,133 --> 00:07:15,066
then we will display our Boolean value of a student
153
00:07:16,066 --> 00:07:18,166
are you a student that is true
154
00:07:19,333 --> 00:07:20,600
with bullion values
155
00:07:20,600 --> 00:07:22,600
we really don't output them directly
156
00:07:22,900 --> 00:07:23,400
you're more
157
00:07:23,400 --> 00:07:26,333
likely to see them used internally within a program
158
00:07:26,366 --> 00:07:28,733
such as when working with if statements
159
00:07:28,933 --> 00:07:30,766
this is a topic we'll discuss in the future
160
00:07:30,766 --> 00:07:31,733
so don't worry
161
00:07:31,966 --> 00:07:33,533
you may see if
162
00:07:34,366 --> 00:07:37,866
is student if this variable is true
163
00:07:38,300 --> 00:07:40,066
then we will print the following
164
00:07:41,700 --> 00:07:43,133
now we don't need to use enough string
165
00:07:43,133 --> 00:07:45,266
we're not going to insert any variables
166
00:07:45,700 --> 00:07:47,666
you are a student
167
00:07:48,133 --> 00:07:51,466
if this were false we can add an L clause
168
00:07:52,466 --> 00:07:53,766
where we will print
169
00:07:54,600 --> 00:07:58,200
you are not a student
170
00:07:59,166 --> 00:08:01,600
our variable of a student is true
171
00:08:02,166 --> 00:08:03,800
we will print the if statement
172
00:08:04,400 --> 00:08:05,666
you are a student
173
00:08:05,933 --> 00:08:09,566
if this were false we will print whatever is within
174
00:08:09,566 --> 00:08:10,366
else
175
00:08:11,066 --> 00:08:12,500
you are not a student
176
00:08:13,166 --> 00:08:15,000
let's think of a few more examples
177
00:08:15,600 --> 00:08:17,400
is something for sale
178
00:08:18,100 --> 00:08:20,600
like a car or a product of some sort
179
00:08:21,333 --> 00:08:22,733
let's say that is true
180
00:08:23,466 --> 00:08:24,966
I'll write another if statement
181
00:08:25,500 --> 00:08:29,700
if for sale if this variable contains true
182
00:08:30,000 --> 00:08:30,900
we will do the
183
00:08:32,200 --> 00:08:33,400
let's print
184
00:08:34,533 --> 00:08:37,466
that item is for sale
185
00:08:38,933 --> 00:08:42,333
else if it's false we will print something else
186
00:08:44,166 --> 00:08:48,733
that item is not available
187
00:08:50,700 --> 00:08:52,766
for sale is set to true
188
00:08:53,700 --> 00:08:55,000
this variable is true
189
00:08:55,000 --> 00:08:57,500
we will print that item is for sale
190
00:08:57,700 --> 00:08:59,166
else if it were false
191
00:09:00,466 --> 00:09:03,700
we print that item is not available
192
00:09:04,733 --> 00:09:05,766
one more example
193
00:09:06,000 --> 00:09:09,400
let's say we have a Boolean variable of is online
194
00:09:09,533 --> 00:09:11,100
is somebody online
195
00:09:11,333 --> 00:09:12,900
I will set that to true
196
00:09:14,966 --> 00:09:20,566
if is online if that's true we will print you are
197
00:09:21,133 --> 00:09:22,000
online
198
00:09:22,733 --> 00:09:24,133
else we will print
199
00:09:24,800 --> 00:09:27,066
you are offline
200
00:09:28,266 --> 00:09:30,266
is online is set to true
201
00:09:30,733 --> 00:09:33,133
we will print you are online
202
00:09:33,566 --> 00:09:37,000
else if it were false we print your offline
203
00:09:38,366 --> 00:09:40,700
alright everybody so those are variables
204
00:09:40,766 --> 00:09:44,066
a variable is a reusable container for a value
205
00:09:44,266 --> 00:09:46,666
there's four basic data types for beginners
206
00:09:46,733 --> 00:09:49,366
a string which is a series of text
207
00:09:49,466 --> 00:09:51,800
integers which are whole numbers
208
00:09:51,933 --> 00:09:52,766
floats
209
00:09:52,966 --> 00:09:55,700
which are numbers but they contain a decimal portion
210
00:09:56,066 --> 00:09:59,800
and booleans which are either true or false
211
00:09:59,800 --> 00:10:03,166
their binary your assignment in the comments section
212
00:10:03,400 --> 00:10:05,400
is to post four variables
213
00:10:05,500 --> 00:10:09,533
post a string an integer a float and a boolean
214
00:10:09,700 --> 00:10:11,733
try and think of a unique example if you can
215
00:10:11,933 --> 00:10:15,133
and well everybody those are variables in Python
14850
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.