Python Data Types - Beginner Python Notes By Mr. Bilred - 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
- Integer (int): Whole numbers
age = 21
- Float: Decimal numbers
pi = 3.14
- String (str): Text
name = "Bilal"
- Boolean (bool): True or False
is_alive = True
- List: Collection of items
fruits = ["apple", "banana", "cherry"]
- Dictionary (dict): Key-value pairs
user = {"name": "Bilal", "age": 21}
- NoneType: Represents nothing
result = None
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
Post a Comment