Knowledgebase

Understanding Python Data Types Print

  • python, guide, howto, solution, zillionkinghost, hosting, support
  • 0

What values are.

NUMBERS

Whole numbers and decimals, handled separately.

TEXT

Strings, written in quotes.

TRUE AND FALSE

Boolean values, used for conditions.

NOTHING

A special value representing the absence of a value.

Distinct from zero or an empty string.

LISTS

Ordered collections that can be changed.

TUPLES

Ordered collections that cannot be changed once created.

DICTIONARIES

Collections of key and value pairs.

SETS

Unordered collections of unique values.

WHY THE DISTINCTIONS MATTER

Each supports different operations, and choosing correctly makes code simpler.

WHAT TO USE WHEN

A list for a sequence of items A dictionary when you look things up by a key A set when uniqueness matters A tuple when the contents must not change

HOW TO CHECK A TYPE

Python can report the type of any value.

Useful when behaviour surprises you.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot