WEBVTT

0
00:06.770 --> 00:12.830
Remember, you should be careful with variables that have global scope, but don't believe the people

1
00:12.830 --> 00:15.590
who tell you that you should never use global scope.

2
00:15.620 --> 00:20.630
Global scope can be incredibly useful, especially when you're defining constants.

3
00:20.630 --> 00:27.290
Global constants are variables which you define and you're never planning on changing it ever again.

4
00:27.290 --> 00:30.690
It's just something like, for example, the value of pi, right?

5
00:31.110 --> 00:35.790
You want to look it up once and you want to put it into your code, and you never want to look it up

6
00:35.790 --> 00:36.900
ever again.

7
00:36.900 --> 00:43.890
And every other time you want to use it, say inside a function, then all you want to do is just tap

8
00:43.890 --> 00:45.720
into that value of pi.

9
00:46.560 --> 00:53.400
So usually in order to differentiate these constants, which you're pretty much never going to change

10
00:53.400 --> 00:56.490
from the variables which you're likely to change,

11
00:56.490 --> 01:01.380
the naming convention in Python is to turn it into all uppercase.

12
01:01.380 --> 01:09.840
For example, if you had PI or you had a URL that you needed to use, then these are all going to be

13
01:09.840 --> 01:12.600
uppercase, separated with underscores.

14
01:12.810 --> 01:20.680
What this means is that later on in your function and you want to use one of these global constants,

15
01:20.950 --> 01:23.800
as soon as you type it, you can see it's uppercase,

16
01:23.800 --> 01:28.810
and you know, to remind yourself to not modify this inside your code.

17
01:30.040 --> 01:35.860
Now that we've talked a little bit about scope, it's time to put your knowledge into action.

18
01:35.860 --> 01:40.750
Head over to the next lesson, and I've got a quiz that will test your understanding.

19
01:40.750 --> 01:42.550
So all of that and more,

20
01:42.550 --> 01:43.240
I'll see you there.