1
00:00:00,000 --> 00:00:02,990
In this chapter, as we look at operators in Python, we are going to be using the

2
00:00:03,000 --> 00:00:07,990
Python Shell which is called Idle in a graphical environment, or in a text

3
00:00:08,000 --> 00:00:11,990
environment, it's simply the Python Interpreter, run from the command line.

4
00:00:12,000 --> 00:00:18,990
Python has all of the standard arithmetic operators. For example, if you say 5 + 5, you get 10.

5
00:00:19,000 --> 00:00:21,990
If say 5 * 5, you get 25.

6
00:00:22,000 --> 00:00:32,990
If you say 5 - 3, you get 2, and if you say 5 / 3, you get this 1.666.

7
00:00:33,000 --> 00:00:36,990
Python also has some thing that they call floor division, which is simply integer division.

8
00:00:37,000 --> 00:00:43,990
If I say 5 with two slashes divide by three then I get 1, which, of course, has

9
00:00:44,000 --> 00:00:45,990
a remainder as well.

10
00:00:46,000 --> 00:00:52,990
So if I say 5 with a percent sign from modulo and a 3, then I get the remainder.

11
00:00:53,000 --> 00:00:57,990
Python also has a built-in function called divmod that gives the two results together.

12
00:00:58,000 --> 00:01:06,990
So if we say Divmod(5, 3), then you get both of those results together as a tuple.

13
00:01:07,000 --> 00:01:11,990
Finally, Python has increment and decrement operators, and they are not quite the

14
00:01:12,000 --> 00:01:13,990
same as you see in some other scripting languages.

15
00:01:14,000 --> 00:01:24,990
If I say num = 5 and I say num += 1, then look at the value of num; we get 6.

16
00:01:25,000 --> 00:01:31,990
If I Say, num -= 1 and we look at the value of num, then we get 5.

17
00:01:32,000 --> 00:01:35,990
There is also a multiplication and division form of these.

18
00:01:36,000 --> 00:01:40,990
So If I say num *= 5, I get 25.

19
00:01:41,000 --> 00:01:48,990
If I say num floor division equals 5, then I get the integer 5.

20
00:01:49,000 --> 00:02:00,990
Of course if I say num *= 5 again and then num with one slash /=5, then we get the

21
00:02:01,000 --> 00:02:02,990
floating point version 5.0.

22
00:02:03,000 --> 00:02:06,990
So those were the basic arithmetic operators that are available in Python.

23
00:02:07,000 --> 00:02:11,990
It has all the standard ones, and a couple that it's implemented in its

24
00:02:12,000 --> 00:02:22,000
own interesting way.

