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