Python Object and Data Structure Basics

Upendra Pratap Kushwaha
Upendra Pratap Kushwha
2 min readJun 3, 2020

This blog post is part of our course Python Tutorial for Ultimate Beginners

Get introduced to Python data structures: learn more about data types and primitive as well as non-primitive data structures, such as strings, lists, sets, etc

Organizing, managing and storing data is important as it enables easier access and efficient modifications. Data Structures allows you to organize your data in such a way that enables you to store collections of data, relate them and perform operations on them accordingly.

In this tutorial, you’ll learn about the various Python data structures and see how they are implemented:

Types of Data Structures in Python

Primitive Data Structures

A primitive data structure is a data type that is inbuilt or considered a basic data structure for a more complex data structure. Primitive means the entity which functions as a building block of something complex. The human cell is a primitive part of our body.

Integers

Just as in mathematics an integer is a whole number that could hold a zero, positive or negative value. This is how you would create various integers in Python:

# positive number 
>>> number = 10
# negative number
>>> negative_number = -25
>>> zero = 0

Float

Float” stands for ‘floating-point number’. You can use it for rational numbers, usually ending with a decimal figure, such as 2.19 or 7.11. This is how you would create floats in Python:

# Floats 
>>> a = 10.12
>>> y = 20.01

More on Numbers in Python

String

The string represents a sequence of characters (text). In Python, you can create strings by enclosing a sequence of characters within a pair of single or double-quotes. For example: 'names', "address", etc.

>>> first_string = "Hello"

More on Strings in Python

Boolean

Booleans are used to represent truth values with two constant objects True and False., which often makes them interchangeable with the integers 1 and 0.

>>> a = True 
>>> b = False

More on Boolean and Sets in Python

Non-Primitive Data Structures

Originally published at https://blog.upendra.tech on June 3, 2020.

--

--

Upendra Pratap Kushwaha
Upendra Pratap Kushwha
0 Followers

Software Engineer — Machine Learning — Python, AWS, SQL