Technical Roadmap

Python Data Types

In the real world, we deal with different types of information like names (words), ages (numbers), and prices (decimals). Similarly, in Python, we have to tell the computer what kind of data we are using. This is called a Data Type. Since Python is smart, it usually figures out the type on its own, but as a developer, you must know how they work.

What is a Data Type?

Think of your computer's memory like a storage warehouse full of different sized boxes. If you have a liquid, you need a bottle; if you have a book, you need a flat box. You can't store water in a paper bag!

In programming, a Data Type is simply a category that tells Python what kind of value a variable holds. It tells the computer two important things: what the value is and what we can do with it. For example, Python knows it can do math with "Numbers," but it can't do math with "Names."

Since Python is Dynamically Typed, you don't have to tell it the type manually. The moment you write x = 10, Python looks at the value and says, "Okay, this is an Integer."

Common Data Types in Python

1. Numeric Types (Numbers)

This is the most basic type. Python handles numbers in two main ways. If you are using a whole number without any point (like 10, 500, or -5), it is called an Integer (int). If the number has a decimal point (like 10.5 or 99.99), it is called a Float.

Python keeps these separate because math with whole numbers is much faster for the computer. However, if you add an Integer and a Float together, Python will automatically turn the result into a Float to make sure no data is lost.

2. String Type (Text)

Whenever you want to use words, sentences, or even just a single letter, you use a String (str). In Python, you must wrap your text in single quotes ' ' or double quotes " ". This tells Python: "Hey, don't try to run this as code; it is just plain text."

For example, "Logicoria" is a string, but Logicoria without quotes would cause an error because Python would think it is a variable name that hasn't been defined yet.

3. Boolean Type (Yes or No)

This is the simplest data type of all. A Boolean (bool) can only have two values: True or False. Think of it like a light switch—it’s either ON or OFF.

We use these constantly in decision-making. For example, if you check is_logged_in = True, your website knows to show the user's dashboard instead of the login page. Note that in Python, True and False must always start with a capital letter.

4. Sequence Types (Lists and Tuples)

Sometimes, you don't want to store just one value; you want to store a whole collection. A List is like a shopping list where you can add, remove, or change items. We write them inside square brackets [ ].

A Tuple is very similar, but it is "immutable." This is a fancy way of saying it cannot be changed once it is created. We write Tuples inside parentheses ( ). Use Tuples for things that should stay the same, like the days of the week.

5. Dictionary Type (Key-Value Pairs)

A Dictionary (dict) is one of the most powerful tools in Python. It works exactly like a real-life dictionary. You have a "Key" (the word) and a "Value" (the meaning).

For example, you could store a student's info like this: {"name": "Rahul", "semester": 2}. Instead of searching through a long list, you can just ask for the "name" and Python will instantly give you "Rahul."