DEV Community

drewmullen
drewmullen

Posted on

3 1

A Python Data Types Chart for the Forgetful

If you're like me, you forget the nuances of each of Python's Data Types. I made this chart as a cheatsheet for myself but I figured I would share it! I will update it with anything I personally find useful! Feel free to comment to add / improve!

Here's to hopefully not needing this chart one day!

Data Type Mutability Iterable Ordered Unique Values Sliceable Instantiate
string immutable s = ""
num immutable i = 0
list mutable x ordered not x L = [], list()
tuple immutable x ordered not x t = (1,), tuple([1,2,3])
range immutable x ordered unique x range(0,3)
dict mutable x unordered unique d={'name': "drew"}, dict(name='drew')
set mutable x unordered unique ms={1,"two"}, set([1,"two",False])
frozenset immutable x unordered unique frozenset([1,"two",False])
bool immutable True, False, bool([])

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →