- Podcasts
- Python To You
- _10 Python Tutorial for Beginners _ Data Types in Python
_10 Python Tutorial for Beginners _ Data Types in Python
Python To You
- October 14, 2026
- 15 min
About this episode
No description.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
_10 Python Tutorial for Beginners _ Data Types in Python
In that particular format, you might face errors or maybe bugs. And trust me, bugs are horrifying. So what are the data types we have here? So let me just list those things here. The first one is none. Second one is numeric. The third one we have is list, tuple, set, string, range, and map. Or you can call it as dictionary. Now let's start with the first one.
Normally, in other languages, we use a keyword as null, but in Python, we use none. The second one is numeric type. Now, if we talk about numeric, we have multiple types here. In fact, we can go with four. The first one is int, then we have float, then we have complex, and we have variable. So, when you talk about numeric, it works with numbers, right? Example, when I say num is equal to 2.5. Now, this is float, okay? So, float value. Now, how do we know that this is float? In fact, in the last session, we have done that, right? So, we can use a type as a function. And in this, you can pass num. And you can say it says class float. Again, we'll talk about class later, okay, what class means. But time bin, it's float, right? Okay, so now I will say another number. I will say num is equal to 5. Of course, we can change the type of variable, right? So now if I assign 5, if I say num, and you can see the class now changed to int. That means the type of this num is int. We also have complex, right? Now what complex means? So I will say num is equal to. Now if you remember mathematics, we used to have this concept of complex numbers, right?
So, we used to say a plus b j. In fact, it was i in complex number, but here we have to use j. Now, we can replace the value of a with a number. I will say 6 plus maybe 9 j. Normally, this j is represented by a square root of minus 1. Okay, now, so when I say enter, you can see it is accepting the value, and if I see the type of this num, It's your complex type. So complex basically means you have a number plus or minus an imaginary number.
float and in this bracket you can pass it and you will get so if I say k you can see we got 5.0 and of course the type of it is float you can check it out later can I convert a normal number into complex number example I have a variable and I have b variable so let me change the value for k and I will assign the k to 6 okay so we got b as 5 and k as 6 Now I want to get a complex number. So I will say C is equal to, how do we get a complex number?
So we can convert the value from, you know, from here to there. In fact, we, we can, we can work with string as well, but we'll see that later. Now, we also have a type called as bull, which is also called as bullion. Now, how can we use a bullion value here? Now, when it comes to bullion, it simply means true and false. Now, think about this computer world, right? In this world, we always take decisions and decisions are based on true or false. In your mind, we always work with these conditions. Example, let's say if you have two choices, you will select those choices which is more.
Is a boolean type right and you can assign that to a variable as well so i will say variable type as bull is equal to b less than k. Now you can see in this bool, if I type bool, you can see it is true. And if I say the type of bool, it's bool itself because it's a type name as well, right? So I should have used a different name here, right? So that's boolean for you. In fact, we have true and we have false as well. Example, if I say B is greater than K and that's not the case, right? B is 5, K is 6. So it should give you false. So we have true and we have false. Again, there are different operators which we can use less than greater than. So we have different operators which we'll discuss in the upcoming videos. But here we can use true or false. But then why I'm keeping true and false in a numeric?
Python, what we do is we we use true as one and false as zero. Example, let's say if I want to convert true into a number, you can say I'm converting that into in format and you can see we got one. The same thing if I do for false, you can see we got zero. So true is one and false is zero. So that's your integer format, you know, that's your numeric type. So we have talked about none, we have talked about numeric. The next type we have is, in fact, we have.
So, this is how you work with list. And how do we know the type of it? So, we will say type of lst. And you can see it says it is of type list. The same thing can be done with set. So, if I create a set here. I will say s equal to and you will use a curly brackets there and inside that you can specify values. So I've specified these values and you can see if I say enter and if I say s you got the values there and you can see it is not repeating and if I define the type of this s it is set. right so even this works now the another type we have is tuple which we have worked with again.
Example i want to print all all even numbers from one from one to ten in that case you can do that you can say i want to have i want to start with or maybe you can start with two And then the ending part is 10 and the difference would be 2 because you want even numbers, right? So you can do that, but you have to put that in a range. Range does take three parameters as well. And you can see we got 2, 4, 6, and 8. So I should have went to 11, right? Because that's the ending part. Okay, so this is how you can use a range. In fact, you can just type here and you can say range.
Normally, what happens, you know, when you have huge amount of data and even when you want to fetch data in an efficient way or in a fast way, what you can do is with every value, you can assign a key. Normally, in list, what we do is for the value, we assign an index number, right? But in dictionary, for every value, we'll assign a key. Example, let's say I want to have all the mobile phones names. Example, so let's say in my friend group, if I have, let's say, 50 phones, Everyone will imagine everyone has a different phone here.
So in this case, every mobile phone has a name or a key attached to it. So it will be easier for you to fetch, right? Okay, now it's not just about string. Okay, you can also use numbers. You can also use, example, roll numbers. Example, when you go for giving your CD exams or entrance exams, you get a number, right?
Let's say D is equal to you have to use a curly brackets. Now why curly packets because keys should not repeat and what doesn't repeat set and set uses curly packets right so it makes more sense here. So I will use a key as let's say Naveen and then I will use a value let's say Naveen has a phone which is Samsung. We can give another value by giving a comma. And here I will say, who has this value? Let's say Rahul.
Okay, so I just missed a colon here, right? So that was my bad. If I try to print D, you can see we got the key and a value pair. So in this case, Naveen, Rahul, and Kiran, those are keys. How do I know those are keys? You can say D dot, you can print the keys, and you can see we got these keys. You got Naveen, Rahul, and Kiran, those are keys. And if you want to get the values, I guess we have a method with values. Yes, we do have a method with values. And if I say enter, you can see Samsung, iPhone and OnePlus. Those are values. Now, how do I get a particular value? Let's say I want to get iPhone here. In this case, I have to use a key, right? Which is Rahul in this case. So I will say D square bracket. If at least we use index numbers, right? We don't have index numbers here. We have a key. So we'll use Rahul as a key. And if I enter, you can see we got iPhone. that's dictionary in fact we have one more way of fetching value instead of using a spare bracket we can also use functions like get in this get you can mention hey i want to fetch let's say kiran's phone which is oneplus right so you can use a square bracket you can use a get method everything works that's how you work with data types so we have different types let me just release those things once again so we have a none we have numeric types we have sequence in sequence we have least range set, tuple, and then we have mapping in which we have dictionary.
