Python Data Types - Beginner Python Notes By Mr. Bilred - TechAmbitionX

Python Data Types — What’s Inside the Box? | TechAmbitionX

Python Data Types — What’s Inside the Box?

So you’ve got a variable, like x = 5

Cool, but what type of thing is that?

In Python, every value has a data type. Think of it like the kind of stuff inside the box.

Common Python Data Types

  1. Integer (int): Whole numbers
    age = 21
  2. Float: Decimal numbers
    pi = 3.14
  3. String (str): Text
    name = "Bilal"
  4. Boolean (bool): True or False
    is_alive = True
  5. List: Collection of items
    fruits = ["apple", "banana", "cherry"]
  6. Dictionary (dict): Key-value pairs
    user = {"name": "Bilal", "age": 21}
  7. NoneType: Represents nothing
    result = None
  8. And remember, List have Square Brackets, And dictionary have Curly braces

How to Check Data Type

You can check what type something is using the type() function:

print(type("Bilal"))  # str
print(type(5))        # int
print(type(3.5))      # float

So yeah — variables hold values, and data types tell you what kind of value.

That’s it for now. Next post? Formatted Strings maybe 😉

Compiled By Bilal Ahmad Khan AKA Mr. BILRED

Help provided as a courtesy. Outcomes and decisions are yours to own
What I Think
"Knowledge Should Be Shared, Only With The One, Who Knows Its True Worth. Not Everyone Deserves It!

Related Topic:

Comments

Popular posts from this blog

Bits, Bytes, Binary, and ASCII: The Fundamentals of Data Representation - Compiled By Bilal Ahmad Khan AKA Mr. BILRED - TechAmbitionX

C++ escape sequences with clear examples and outputs - Compiled By Bilal Ahmad Khan AKA Mr. BILRED

C++ Prog Lang In A Nutshell VOL #2 Compiled By Bilal Ahmad Khan AKA Mr. BILRED - TechAmbitonX