DEV Community

Cover image for Introduction to Python data objects.
Kelechi Kizito Ugwu
Kelechi Kizito Ugwu

Posted on

Introduction to Python data objects.

Python expressions create and process objects. “Object” is essentially anything that you can assign to a variable.

Python’s core object types include;
Numbers
Strings
Lists
Dictionaries
Tuples
Files
Sets

Numbers are numerical data types which include; integers, floating-point numbers and more exotic numerical types(complex numbers).

Image description

Strings are textual data types as well as arbitrary collection of bytes. Strings are known as sequence —that is, a positionally ordered collection of other objects. They are enclosed in double or single quotation marks.

Image description

List is a positionally ordered sequence of arbitrary object types. They have no fixed size and are enclosed in square brackets.

Image description

Dictionaries are also known as mappings. Mappings store objects in a key-value pair. They are enclosed in curly brackets.

Image description

A tuple is a collection of objects which ordered and immutable. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

Image description

Files are python’s code interface into external files.

Image description

Set is an unordered and mutable collection of objects. Sets are enclosed in curly brackets.

Image description

Why use Object types?

-Object types make programs easy to write. With object types like Lists and Dictionaries which offer collections and search tables for free respectively make it easier to write programs.
-Built-in objects are often more efficient than custom data structures.
-Built-in objects are a standard part of the language.

Top comments (0)