WEBVTT 1 00:00:00.590 --> 00:00:02.110 Hi guys and welcome back. 2 00:00:02.110 --> 00:00:04.200 In this video we're going to learn about numbers 3 00:00:04.200 --> 00:00:05.643 and mathematics in Python. 4 00:00:06.640 --> 00:00:08.830 You've got two main types of numbers, 5 00:00:08.830 --> 00:00:11.510 and that is integers, or whole numbers, 6 00:00:11.510 --> 00:00:15.480 and floating point numbers, or numbers with a decimal place. 7 00:00:15.480 --> 00:00:19.720 For example, if we do age equal 35, this is an integer, 8 00:00:19.720 --> 00:00:24.623 and if we do PI equal 3.14159, this is a float. 9 00:00:25.730 --> 00:00:29.390 Notice that the variable name itself is largely irrelevant 10 00:00:29.390 --> 00:00:31.910 in this explanation, what matters is the value. 11 00:00:31.910 --> 00:00:33.840 Here we've got a whole number, 12 00:00:33.840 --> 00:00:36.150 a number that doesn't have a decimal place, 13 00:00:36.150 --> 00:00:38.350 and here we've got a number with a decimal place, 14 00:00:38.350 --> 00:00:39.863 so this is a float. 15 00:00:41.690 --> 00:00:43.880 Anywhere in Python you can also use 16 00:00:43.880 --> 00:00:47.080 the hash symbol to write a comment. 17 00:00:47.080 --> 00:00:50.070 So here we have something called an integer, 18 00:00:50.070 --> 00:00:52.840 and here we have a float, and what happens is 19 00:00:52.840 --> 00:00:54.870 when Python goes through this code, 20 00:00:54.870 --> 00:00:57.570 it ignores everything that comes after the hash symbol 21 00:00:57.570 --> 00:00:59.830 so you can use it to write comments for yourself, 22 00:00:59.830 --> 00:01:02.150 to remind yourself of what things are, 23 00:01:02.150 --> 00:01:05.130 or as notes for studying later on. 24 00:01:05.130 --> 00:01:07.370 Mathematics works just as normally, 25 00:01:07.370 --> 00:01:10.320 so we can have a variable called maths operation 26 00:01:10.320 --> 00:01:13.190 and make it equal to one plus three, times four, 27 00:01:13.190 --> 00:01:16.260 divided by two minus two, making use of all the major 28 00:01:16.260 --> 00:01:20.260 mathematical symbols, and just as in normal maths, 29 00:01:20.260 --> 00:01:23.770 the PEMDAS or BODMAS rules are followed, 30 00:01:23.770 --> 00:01:27.040 so multiplication is evaluated first, then division, 31 00:01:27.040 --> 00:01:29.230 then addition, and then subtraction. 32 00:01:29.230 --> 00:01:32.350 So here we would have 12 divided by two is six, 33 00:01:32.350 --> 00:01:34.940 one plus six is seven, minus two is five, 34 00:01:34.940 --> 00:01:39.400 and you can verify that by printing it out, 35 00:01:39.400 --> 00:01:42.560 so I'm gonna press run now and we see 5.0 36 00:01:42.560 --> 00:01:43.880 gets printed out there. 37 00:01:43.880 --> 00:01:47.160 This is an important part of mathematics in Python because 38 00:01:47.160 --> 00:01:52.160 whenever you do division, you always get a float, 39 00:01:52.250 --> 00:01:55.780 even if the result is essentially something point zero, 40 00:01:55.780 --> 00:01:57.600 which is basically a whole number, 41 00:01:57.600 --> 00:01:59.510 you always get back a float. 42 00:01:59.510 --> 00:02:01.800 So if we do something like float division, 43 00:02:01.800 --> 00:02:04.810 and we say 12 divided by three, and we print it out, 44 00:02:04.810 --> 00:02:07.270 and I'm just gonna delete this code here for simplicity, 45 00:02:07.270 --> 00:02:08.800 so if we do something like this, 46 00:02:08.800 --> 00:02:12.020 you'll see that we get 4.0 back. 47 00:02:12.020 --> 00:02:15.130 If you want to get rid of the floating point, 48 00:02:15.130 --> 00:02:17.930 or the decimal place, you can do integer division. 49 00:02:17.930 --> 00:02:19.800 So here I'm gonna create a new variable called 50 00:02:19.800 --> 00:02:22.400 integer division, you can call it whatever you want though, 51 00:02:22.400 --> 00:02:24.350 remember these are just names, 52 00:02:24.350 --> 00:02:27.770 and I'm gonna do 12 divide divide three, 53 00:02:27.770 --> 00:02:29.910 and what this does is it performs the division 54 00:02:29.910 --> 00:02:32.360 and then removes everything after the decimal place, 55 00:02:32.360 --> 00:02:34.810 so this can come in handy at times. 56 00:02:34.810 --> 00:02:39.280 So, if we run that you see that you get 4.0 first 57 00:02:39.280 --> 00:02:40.990 from this first print statement 58 00:02:40.990 --> 00:02:43.350 and then just four for the second one. 59 00:02:43.350 --> 00:02:46.810 Notice that if we change this to eight divided by three, 60 00:02:46.810 --> 00:02:49.093 the floating point division is two point six, 61 00:02:50.020 --> 00:02:52.230 but the integer division is two. 62 00:02:52.230 --> 00:02:55.390 This here does not round the numbers up and down, 63 00:02:55.390 --> 00:02:58.100 it just removes everything after the decimal place, 64 00:02:58.100 --> 00:03:00.090 so this is something to keep in mind as you do 65 00:03:00.090 --> 00:03:02.420 integer division later on. 66 00:03:02.420 --> 00:03:03.640 That's everything for this video, 67 00:03:03.640 --> 00:03:06.383 thank you for joining me, and I'll see you in the next one.