WEBVTT

00:00.590 --> 00:08.930
Numbers are used quite often in programming to keep scoring games, represent data visualization, stored

00:08.930 --> 00:11.240
information in web applications and so on.

00:11.270 --> 00:18.020
So Python threads numbers in several different ways depending on how they are being used.

00:18.200 --> 00:24.620
Let's first look at how Python manages integers because they are the simplest to work with.

00:25.360 --> 00:25.630
Here.

00:25.630 --> 00:26.580
We will do it.

00:26.610 --> 00:28.590
This run again.

00:28.600 --> 00:30.130
Here now.

00:32.330 --> 00:35.570
Firstly, we will start with integers.

00:35.720 --> 00:37.760
Now let's change the color.

00:43.190 --> 00:44.330
Integers.

00:47.010 --> 00:49.620
So you can do math with integers, of course.

00:49.620 --> 00:51.060
Here now.

00:53.640 --> 01:03.750
For example, my integer or my value here, two plus three and print my value.

01:04.580 --> 01:05.140
I see here.

01:05.140 --> 01:06.430
Five two plus nine.

01:06.480 --> 01:07.330
Nine nine.

01:10.770 --> 01:11.580
Doesn't one.

01:12.480 --> 01:14.400
You can do subtraction.

01:16.710 --> 01:19.370
And it's 9.97 multiplication.

01:21.160 --> 01:22.120
And division.

01:24.620 --> 01:26.360
In terminal session.

01:26.360 --> 01:33.500
Python simply returns the results of the operation, and Python uses two multiple action symbols to

01:33.500 --> 01:35.600
represent exponents.

01:35.810 --> 01:39.050
So here this is exponent exponential here.

01:39.050 --> 01:41.630
As you can see here, there's a lot of numbers here.

01:42.630 --> 01:42.930
Go.

01:44.650 --> 01:48.160
You can see here, we can do this.

01:52.440 --> 01:54.140
The second one I show here.

01:54.140 --> 02:01.400
So Python supports the order of operations too, so you can use multiple operations in one expression.

02:01.400 --> 02:08.270
So you can also use parentheses to modify the order of operations so Python can evaluate your expression

02:08.270 --> 02:12.650
in the order you specify, for example, like this.

02:13.190 --> 02:19.790
Uh, two plus two plus nine, multiply by four.

02:21.040 --> 02:22.900
Here it's 44.

02:22.900 --> 02:29.740
And the spacing in these examples has no effect on how Python evaluates the expressions here.

02:34.230 --> 02:35.040
Like this.

02:35.550 --> 02:36.000
This will.

02:36.330 --> 02:39.240
But this has no effect on Python.

02:39.390 --> 02:47.040
But it simply helps you more more quickly spot operations that have priority in your reading throughout

02:47.070 --> 02:48.750
your code.

02:49.710 --> 02:53.310
And we also have lots.

03:06.140 --> 03:13.370
So Python calls any number with a decimal point a float.

03:13.730 --> 03:20.060
This term is used in most programming languages, and it refers to the fact that a decimal point can

03:20.060 --> 03:23.300
appear at any position in a number.

03:23.330 --> 03:28.430
Every programming language must be carefully designed to appropriately manage decimal numbers so numbers

03:28.430 --> 03:31.940
behave appropriately no matter where the decimal point appears.

03:31.970 --> 03:37.210
So for the most part, you can use floats without worrying about how they behave.

03:37.220 --> 03:44.450
Simply enter the number numbers you want to use and the python will most likely do what you expect.

03:44.720 --> 03:46.490
Like this here for example.

03:46.490 --> 03:49.700
0.1 multiply by or.

03:53.020 --> 03:57.800
0.9 here it's 1.0999.

03:58.060 --> 04:01.100
1.099.

04:01.180 --> 04:05.440
And we also have here sample.

04:06.540 --> 04:06.990
Do.

04:07.900 --> 04:12.340
1999 multiply by 0.1.

04:13.330 --> 04:15.810
And 9.9.

04:15.960 --> 04:22.200
However, be aware that you can sometimes get an arbitrary number of decimal places in your answer.

04:22.530 --> 04:30.540
For example, this 0.90.2 here plus 3.1.

04:31.020 --> 04:33.330
And as you can see here, we get this.

04:33.540 --> 04:38.910
So this happens in all languages and this is of little concern.

04:38.910 --> 04:46.560
So Python tries to find a way to represent the results as precisely as possible, which is sometimes

04:46.560 --> 04:51.120
difficult, even how computers have to represent numbers internally.

04:51.120 --> 04:56.880
So just ignore the extra decimal places for now so you will learn ways to deal with the extra places

04:56.880 --> 05:01.530
when you need to in the projects of Part two.

05:01.890 --> 05:09.240
And we also said so when you divide in two numbers, even if they are integers that result in a whole

05:09.240 --> 05:10.020
number.

05:10.020 --> 05:18.700
So you will always get the float here, for example, divide four by two and the 2.0.

05:18.700 --> 05:26.070
So if you mix an integer and a float in any other operation, you will get a float as well.

05:26.080 --> 05:33.670
Look, this oops here, one one plus 5.0.

05:33.670 --> 05:36.190
And as you can see, it's 6.0.

05:36.400 --> 05:41.740
So Python defaults to a float in any operation that use the flow.

05:41.740 --> 05:44.410
So even if the output is a whole number.

05:45.550 --> 05:52.210
We also have underscores in numbers, which you will learn in next lecture.
