Definition
📌 Data Types
Python's core built-in types include int (whole numbers), float (decimals), str (text), and bool (True/False).
Syntax
syntax
int, float, str, bool, list, tuple, dictExample
py
age = 20 # int
gpa = 8.9 # float
name = "CodeyHub" # str
passed = True # bool
print(type(age), type(gpa), type(name), type(passed))Output
output<class 'int'> <class 'float'> <class 'str'> <class 'bool'>
Important Points
boolvalues are capitalized in Python:TrueandFalse.intin Python has no overflow limit, unlike C/Java's fixed-size integers.- Use
int(x),float(x), orstr(x)to explicitly convert between types. type()lets you inspect a value's exact type at any point.
Common Mistakes
- Writing
true/falselowercase — Python requires capitalizedTrue/False. - Trying to concatenate a string and a number directly with
+without converting first. - Assuming Python's
inthas the same size limits as C or Java'sint.
Interview Tip
🎯 Before your interview
Know that Python's dynamic typing doesn't mean "no types" — every value has a concrete type, checked at runtime rather than declared upfront.
