Podcast Lookup

_10 Python Tutorial for Beginners _ Data Types in Python

Python To You

  • October 14, 2026
  • 15 min
Episode page

About this episode

No description.

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

_10 Python Tutorial for Beginners _ Data Types in Python

00:00—
  1. Speaker 1

    Welcome back to Aliens.

  2. Speaker 2

    My name is Navin Reddy and let's continue with this series of Python. And in this video, we'll talk about one of my favorite topics, which is called as data types.

  3. Speaker 1

    Now, why it's so important? Because we have worked with variables, right? And everything was working.

  4. Speaker 2

    Now, when you work on a project, it's very important to understand what type of data you're working with so that you can process that data in that format.

  5. Speaker 1

    Because if you don't process the data.

  6. Speaker 2

    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.

  7. Speaker 1

    The first one is none. Know what it means?

  8. Speaker 2

    Now, when you have a variable and if that variable is not assigned with any value.

  9. Speaker 1

    It is none.

  10. Speaker 2

    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?

  11. Speaker 1

    Now, how do we represent complex numbers?

  12. Speaker 2

    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.

  13. Speaker 1

    Okay, now this works.

  14. Speaker 2

    So we have int, we have float, and we have complex. So can I convert from a different type? Example, I have a value which is float, and I want to convert that into integer.

  15. Speaker 1

    Is it possible? Let's try.

  16. Speaker 2

    So what I will do here is I will take a variable called as a, and the value in A I will assign as 5.6. I have another variable which is B, and I want to assign the int value of A.

  17. Speaker 1

    Can I convert it?

  18. Speaker 2

    Because if I see the type of A, it's float, right?

  19. Speaker 1

    I want to.

  20. Speaker 2

    Get the type of B as int, and only I want to have.

  21. Speaker 1

    The value which is 5.

  22. Speaker 2

    So in that case, you will be using an int function in which you will pass A. So this int function will convert your float value or any value into integer format.

  23. Speaker 1

    And that works. Now if I say... The type of B, it's int, and the value of B is 5, right?

  24. Speaker 2

    So we can convert that. Can I convert an int value into float? Yes, we can. So let's say we have another variable, which is K, and I want to fetch the value of B, but not in the int format.

  25. Speaker 1

    I want in float format. Yes, we can do that. So I can say.

  26. Speaker 2

    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?

  27. Speaker 1

    It's very simple. Just use a complex function that the way we are doing.

  28. Speaker 2

    And then you can pass two variables here or one, only one parameter that when that works, if I want to pass two parameters, I can pass B comma K. And if I say C, you can see the value now.

  29. Speaker 1

    So it says five plus six J because five is your B and six is your K. Okay. So it works.

  30. Speaker 2

    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.

  31. Speaker 1

    Favorable or which will be more profitable, right? So, we apply conditions there.

  32. Speaker 2

    So if that is more profitable we'll go there if this is more profitable it will go here now the same way we apply a condition and we get true.

  33. Speaker 1

    Or false so that true or false comes under boolean type now we have b and k right so if i want to check if b is less than k we can do that so less than symbol is less than and if i say enter you can see we got true so true here.

  34. Speaker 2

    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?

  35. Speaker 1

    It should be different, right? The thing is, in.

  36. Speaker 2

    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.

  37. Speaker 1

    Discussed those names, right? Those things comes under sequence.

  38. Speaker 2

    So when you say list, range, set, tuple, those things comes under sequence.

  39. Speaker 1

    Now, we have worked with list before, right? So, how do we define list? It's very simple. You will say lst equal to, you can define list here. So, I can say 25, 36, 45, 12. Any number, any format doesn't matter. You can take string as well.

  40. Speaker 2

    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.

  41. Speaker 1

    So i will say t is equal to so we have to use a down bracket.

  42. Speaker 2

    Here i will say 25 26 you can use any format doesn't matter right you can see we got t and if i say type of t here is tuple okay now we also have.

  43. Speaker 1

    A string type Right. So how do we define a string type? It's very simple.

  44. Speaker 2

    You say STR is equal to and you can specify a name here using double quotes or single quotes.

  45. Speaker 1

    Both works. I can say my name. That's Naveen.

  46. Speaker 2

    And using using STR, you can perform certain operations. Again, we have done that in detail in the in earlier videos.

  47. Speaker 1

    Right.

  48. Speaker 2

    So if you want to know more about Laced and Tuple, you can go back to the previous videos and you can watch it. In this video, we are just talking about the data types available.

  49. Speaker 1

    How about character? Because we have not talked about character, right?

  50. Speaker 2

    And if you are coming from some other languages like Java, C, C + +, we do have a char type there. Now, in Python, we don't have a char type.

  51. Speaker 1

    What we have is if you are creating a string, let's say I will say this is st is equal to and if you have a single digit or single character, that's a char type for you. But actually it is string because even if you.

  52. Speaker 2

    Say type and if you specify st you can see it says class str which is string in this case. So we have string we don't have char as to be specific but we can use char as a part of string. Now we have another fancy stuff which is there in Python but not in other languages called as range.

  53. Speaker 1

    Example, you know, when you iterate, what is iteration means?

  54. Speaker 2

    Going from one value to the other, examples from 1 to 10 or 10 to 100 or maybe from 1 to 1000. So when we iterate between values, We can use a range. How do we define range?

  55. Speaker 1

    It's very simple.

  56. Speaker 2

    You say range and you give a curly package and specify the range. Example, I want to I want to go till 10. So we got a range from zero and we have 10 values, which is zero to nine.

  57. Speaker 1

    How do we know which what values we have?

  58. Speaker 2

    What we can do is we can actually convert the range into a list so that we can print it right so what i will do is i will say list of range and we'll say 10.

  59. Speaker 1

    In fact there's another way of doing this.

  60. Speaker 2

    We can also use a for loop but unfortunately we have not done that yet so we'll not be focusing on for loop here because we have a better way of printing it But as of now, just to get the output of the range, I'm converting.

  61. Speaker 1

    A range into a list so that they can see the output. And you can see this is the list of this is the range.

  62. Speaker 2

    So if I want to get a list of, let's say, 10 values from zero to nine, we will use a range there. OK, but you might be saying, well, what if I want to have a range with.

  63. Speaker 1

    Different iterations, maybe a different difference?

  64. Speaker 2

    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.

  65. Speaker 1

    Of course, right?

  66. Speaker 2

    It will give you range as you can. It will give you range type. So that's one type you can use. And all these things comes under sequence, right? Because we are getting a sequence of values. And now we have one of the most exciting type, which is called as mapping.

  67. Speaker 1

    Or you can say dictionary. Now, what is dictionary?

  68. Speaker 2

    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.

  69. Speaker 1

    So we can, of course, we can do index number, right?

  70. Speaker 2

    So index number zero, iPhone 6S, index number one, Samsung, maybe Samsung J8, index number three, OnePlus 3, index.

  71. Speaker 1

    Number four, let's say MI5. So we want to have all these numbers.

  72. Speaker 2

    Now instead of having index numbers, we can use a key, which is your name. Example, who has one plus three? Let's say Kiran, who has iPhone 6s? Let's say Rahul, who has Samsung?

  73. Speaker 1

    Let's say Navin.

  74. Speaker 2

    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?

  75. Speaker 1

    That's your key.

  76. Speaker 2

    So you can identify each object with a key. How do I do that here? Oh, there's one thing to remember. Key should be unique. So if you have a.

  77. Speaker 1

    Dictionary, all the keys has to be unique and values you can repeat values. Let's try it out. How do we define a dictionary? It's very simple.

  78. Speaker 2

    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.

  79. Speaker 1

    Rahul is using, let's say, iPhone. And then we have one more. Let's say Kiran. And Kiran is using OnePlus. Okay. Now this is, oh, I made a mistake there.

  80. Speaker 2

    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.

  81. Speaker 1

    So I hope it makes sense.

  82. Speaker 2

    So if you have any questions, let me know in the comment section and do click the like button if you're enjoying this session.