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).
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.
List is a positionally ordered sequence of arbitrary object types. They have no fixed size and are enclosed in square brackets.
Dictionaries are also known as mappings. Mappings store objects in a key-value pair. They are enclosed in curly brackets.
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.
Files are python’s code interface into external files.
Set is an unordered and mutable collection of objects. Sets are enclosed in curly brackets.
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)