1 00:00:00,920 --> 00:00:01,530 Welcome back. 2 00:00:02,090 --> 00:00:09,950 Let's talk about our first data type and you know what, let's do two at the same time we have Int and 3 00:00:09,950 --> 00:00:19,820 float's int stands for Integer, as you can see here, and float stands for a floating point number. 4 00:00:20,710 --> 00:00:32,290 Hmm, let's explore that first, let's start off with integer, an integer is, well, a number three 5 00:00:32,800 --> 00:00:34,470 or four or five. 6 00:00:34,750 --> 00:00:36,460 These are all integers. 7 00:00:37,470 --> 00:00:45,690 In a programming language, you can use integers to do mathematical operations, for example, two plus 8 00:00:45,960 --> 00:00:54,720 four, if I run this well, nothing gets printed because again, we have to perform some action on these 9 00:00:54,720 --> 00:00:55,350 data types. 10 00:00:55,680 --> 00:01:00,870 And one action that we've learned so far is this idea of printing. 11 00:01:02,850 --> 00:01:08,910 And we print something by calling the print keyword with the brackets. 12 00:01:09,980 --> 00:01:15,980 So the brackets is almost like saying, hey, perform this action on these data types. 13 00:01:17,470 --> 00:01:18,850 And if we run this. 14 00:01:20,820 --> 00:01:24,060 We get six right here, awesome. 15 00:01:25,060 --> 00:01:31,780 So not only are we using print, but we're also using the plus sign to perform an action to add the 16 00:01:31,780 --> 00:01:32,980 two data types together. 17 00:01:34,010 --> 00:01:36,320 And as you can imagine, we can do. 18 00:01:37,310 --> 00:01:45,170 Most mathematical operations, the basic ones we can do negative, we can do, let's say, two times 19 00:01:45,620 --> 00:01:46,100 for. 20 00:01:48,030 --> 00:01:53,190 And then we can also do two divided by four and in fact, click run here. 21 00:01:54,570 --> 00:01:56,610 All right, it looks like everything is working. 22 00:01:57,360 --> 00:02:03,090 We've added, we've subtracted, we've multiplied, and then we've also divided. 23 00:02:04,630 --> 00:02:06,340 Now, here's the interesting part. 24 00:02:07,610 --> 00:02:10,760 Up until now, we've used what we call integers. 25 00:02:11,750 --> 00:02:18,920 That is, these are whole numbers, there's no decimal places, they're just, well, integers. 26 00:02:20,220 --> 00:02:24,330 And a neat trick that I can do here is I can actually say. 27 00:02:25,440 --> 00:02:30,810 Hey, what's the type of two plus four? 28 00:02:32,960 --> 00:02:34,280 If I click run here. 29 00:02:35,580 --> 00:02:37,940 All right, let's let's decipher what just happened. 30 00:02:39,590 --> 00:02:44,750 I've taught you another action that we can perform, which is something called type, which tells us, 31 00:02:44,930 --> 00:02:47,330 hey, what data type is this? 32 00:02:48,620 --> 00:02:56,300 And just like in math, we go bracket by bracket, so the first part, Python says, hey, what's two 33 00:02:56,300 --> 00:02:56,850 plus four? 34 00:02:57,170 --> 00:02:59,180 Well, that's going to be six. 35 00:03:00,290 --> 00:03:03,990 And it's going to say, hey, what's the type of sex? 36 00:03:04,550 --> 00:03:06,970 Well, the type of sex that's an integer. 37 00:03:07,010 --> 00:03:13,160 So it's going to say class and we don't have to worry about the class keyword for now. 38 00:03:13,160 --> 00:03:14,780 That's something that we'll talk about later. 39 00:03:14,960 --> 00:03:18,050 But we see here that we're using it for integer. 40 00:03:18,500 --> 00:03:25,970 And then finally, after this gets evaluated by Python, we print out whatever this does, which is 41 00:03:25,970 --> 00:03:26,810 class int. 42 00:03:28,460 --> 00:03:32,500 Now, check this out, let's do the same for all these ones as well. 43 00:03:33,760 --> 00:03:37,390 So we're going to say type here type. 44 00:03:43,200 --> 00:03:48,040 Here and if this syntax is intimidating, don't worry, this is something that you get used to. 45 00:03:48,210 --> 00:03:49,860 This is your first programming language. 46 00:03:50,190 --> 00:03:55,370 It is not going to be easy because, well, if it was easy, then everybody would be doing it. 47 00:03:55,650 --> 00:03:56,730 So hang in there. 48 00:03:56,940 --> 00:04:01,310 Trust me, as you practice more, this is going to start making more and more sense. 49 00:04:02,250 --> 00:04:03,600 Now, before I click run. 50 00:04:04,200 --> 00:04:07,890 What do you think the output of each one of these lines are? 51 00:04:09,800 --> 00:04:10,200 Ready? 52 00:04:10,670 --> 00:04:12,260 Give it a guess and let's click on. 53 00:04:15,390 --> 00:04:17,610 All right, we got it. 54 00:04:18,850 --> 00:04:26,140 For six, we have negative two here, which is also an integer, we have eight here, which again is 55 00:04:26,140 --> 00:04:29,860 also an integer, but then we have float. 56 00:04:31,700 --> 00:04:34,640 Because two divided by four is zero point five. 57 00:04:35,370 --> 00:04:37,250 Hmm, what is that? 58 00:04:37,730 --> 00:04:41,150 Well, remember, we are talking about two data types here. 59 00:04:41,360 --> 00:04:44,240 We're talking about Int and float. 60 00:04:45,130 --> 00:04:53,500 And float is what we call a floating point number, a floating point number is simply a number with 61 00:04:53,500 --> 00:04:54,520 a decimal point. 62 00:04:54,790 --> 00:04:58,750 In our case, this is zero point five. 63 00:04:58,780 --> 00:05:00,580 So it's a floating point number. 64 00:05:02,300 --> 00:05:10,940 So if we write a number, let's say we'll do print type and then I'll say zero point zero zero zero 65 00:05:10,940 --> 00:05:11,600 zero one. 66 00:05:12,790 --> 00:05:13,690 What do you think we'll get? 67 00:05:14,050 --> 00:05:17,020 Well, we would get a float. 68 00:05:18,330 --> 00:05:23,070 If I do five point zero zero zero one again, we'll get a float. 69 00:05:24,170 --> 00:05:26,180 What about the number zero? 70 00:05:30,600 --> 00:05:34,980 I get an ENT because while there's no decimal points. 71 00:05:36,440 --> 00:05:41,990 Why do we need to make this distinction in programming and specifically in Python? 72 00:05:42,860 --> 00:05:49,880 Well, it's because a float takes up actually a lot more space in memory than an integer. 73 00:05:50,090 --> 00:05:50,480 Right? 74 00:05:51,200 --> 00:06:00,940 Because remember this number, the number six, this needs to get stored in memory on our machine. 75 00:06:01,580 --> 00:06:05,570 And remember that machines don't really understand this. 76 00:06:05,600 --> 00:06:13,760 They understand zeros and one and they store this number and something called a binary or binary numbers, 77 00:06:13,940 --> 00:06:15,470 which is zeros and ones. 78 00:06:16,280 --> 00:06:24,560 Now, the problem is when you have a decimal places like zero point or less to ten point five six, 79 00:06:25,490 --> 00:06:31,080 it's hard to represent that in a binary number, zeros and ones because of this point. 80 00:06:31,520 --> 00:06:39,530 So a floating point number essentially stores these numbers in two different locations, one for the 81 00:06:39,650 --> 00:06:42,380 ten and one for fifty six. 82 00:06:43,500 --> 00:06:49,290 Now, we don't need to get technical here, but that's the idea, the idea is that we need more memory 83 00:06:49,290 --> 00:06:53,310 to store a number like this than a number like this. 84 00:06:54,480 --> 00:06:59,340 Now, the topic of floating point numbers is really, really interesting, and I'll link to a resource, 85 00:06:59,580 --> 00:07:04,920 but the best way to learn more about floating points, again, it's not super important that you know 86 00:07:04,920 --> 00:07:11,220 the technical details, but if you go to a floating point, no python. 87 00:07:13,800 --> 00:07:17,880 Again, you want to make sure that you go to the documentation for version three. 88 00:07:19,840 --> 00:07:26,500 And you can actually learn about floating point arithmetic and these official documentation by Python 89 00:07:26,500 --> 00:07:31,810 are always a good tool for you to use whenever you get confused about something or you want to get a 90 00:07:31,810 --> 00:07:33,580 little bit more extra detail. 91 00:07:35,920 --> 00:07:37,900 But let's get back to the topic at hand. 92 00:07:40,020 --> 00:07:48,900 Both eat and float are used for, well, numbers, right, and Python is going to automatically format 93 00:07:49,200 --> 00:07:56,280 the type to whatever well makes sense, for example, if in here. 94 00:07:57,140 --> 00:07:57,770 I do. 95 00:07:58,760 --> 00:08:02,120 Twenty plus one point one. 96 00:08:03,080 --> 00:08:10,040 One is a integer, the other one is a floating point number, but when I click run here. 97 00:08:11,070 --> 00:08:17,610 Automatically, Python is going to convert it to float, let's remove these here so that we don't get 98 00:08:17,610 --> 00:08:18,380 confused by them. 99 00:08:19,470 --> 00:08:26,260 So if I run this, we see that this whole expression is converted into, well, a float. 100 00:08:27,010 --> 00:08:32,550 Now, if I do, let's say nine point nine here. 101 00:08:34,040 --> 00:08:42,800 Which will equal to 11 and I click run these two floats, add up to while still a floating point number, 102 00:08:43,010 --> 00:08:47,690 because if I remove the type from here and I click run. 103 00:08:49,770 --> 00:08:53,230 It gives me the result, eleven point zero. 104 00:08:53,820 --> 00:08:57,150 It keeps the floating point numbers all right. 105 00:08:57,390 --> 00:09:01,830 But at the end of the day, what we care about is that that python works. 106 00:09:01,830 --> 00:09:06,240 The way we expect it to do that is we can do mathematical operations. 107 00:09:06,810 --> 00:09:10,130 As a matter of fact, we can do a few other things as well. 108 00:09:12,180 --> 00:09:17,790 There's also this idea of the double multiply. 109 00:09:19,080 --> 00:09:22,950 So this means to the power of so to to the power of two. 110 00:09:23,700 --> 00:09:26,310 Well, that's going to equal four. 111 00:09:27,500 --> 00:09:31,460 Due to the power of three is going to equal eight. 112 00:09:33,630 --> 00:09:37,590 We also have the double divide. 113 00:09:38,670 --> 00:09:47,130 That is, we can do to divide it by four, but then we used to slash this year if I click run here. 114 00:09:49,480 --> 00:09:50,770 I get zero. 115 00:09:52,290 --> 00:09:55,560 This actually returns an integer. 116 00:09:56,510 --> 00:10:01,010 Round it down if I do three divided by four. 117 00:10:02,720 --> 00:10:07,010 I get zero, but if I do five divided by four. 118 00:10:11,140 --> 00:10:14,770 This gets rounded down to a integer. 119 00:10:16,290 --> 00:10:23,520 Finally, the last operator that we're going to learn about is called Modula, and it looks something 120 00:10:23,580 --> 00:10:29,280 like this if I do five modulo, which is the percent sign. 121 00:10:30,590 --> 00:10:35,630 Divided by four or modulo four, five, run this. 122 00:10:40,790 --> 00:10:46,760 Modulo is used to represent what's the remainder of this division. 123 00:10:46,970 --> 00:10:55,520 So if I divide five by for the remainder of this division will be one if I do six divided by four with 124 00:10:55,520 --> 00:10:58,940 Modula and I run, I get to. 125 00:10:59,930 --> 00:11:02,060 Two is the remainder of four. 126 00:11:03,020 --> 00:11:08,720 All right, let's take a break and learn a little bit more about these numbers in the next video by.