Home
Python
Python: Data Types
Daniel Nguyen
Daniel Nguyen
September 01, 2026
1 min

Python data types define the kind of value a variable holds and the operations that can be performed on it. Python is dynamically typed, so you don’t need to declare variable types explicitly.

1. Basic Data Types

name = "Viet" # str
age = 25 # int
price = 99.99 # float
is_active = True # bool
result = None # NoneType

Use type() to inspect a value’s type:

print(type(age)) # <class 'int'>

2. Collection Types

Python provides four common collection types:

TypeCharacteristics
listOrdered, mutable, allows duplicates
tupleOrdered, immutable, allows duplicates
setUnordered, unique elements
dictKey-value pairs, mutable, unique keys
numbers = [1, 2, 2, 3] # list
coordinates = (10, 20) # tuple
unique_numbers = {1, 2, 3} # set
user = {"name": "Viet", "age": 25} # dict

3. Type Conversion

Convert values using built-in functions such as int(), float(), str(), and bool().

age = int("25")
price = float("19.99")
message = str(100)

Invalid conversions can raise exceptions, such as ValueError.

4. Dynamic Typing vs. Type Hints

Python allows a variable to reference values of different types.

value = 10
value = "hello"

Type hints document expected types and support static analysis, but Python does not enforce them automatically at runtime.

def add(a: int, b: int) -> int:
return a + b

Tags

#Python

Share

Daniel Nguyen

Daniel Nguyen

Frontend Developer

Frontend developer specializing in React, Next.js, and JavaScript. Writing practical guides on modern web development at Dev98.

Expertise

React
Next.js
JavaScript
TypeScript
Python

Social Media

githublinkedinyoutubewebsite

Related Posts

AI
Building an AI Gateway with FastAPI
October 06, 2026
2 min
Dev98

Dev98

React · Next.js · Web development