Author: Michael Robinson
email: michael.robinson@fiu.edu
updated: May 5th, 2025
================================
Python Data Types
Python has the following data types, which are built-in by default:
boolean
Python has the usual boolean values used by all languages, as follow:
True
False
Text Data Type: str
str data type accepts/contains alphabetic letters, spaces, numbers
and/or symbols such as &,*,# and others.
Examples:
myFirstName = "Michael"
myLastName = "Robinson"
myAddress = "123 Main Avenue, Jefferson, NY, 11011"
In these cases myFirstName, myLastName and myAddress are the variable names,
"Michael", "Robinson" and "123 Main Avenue, Jefferson, NY, 11011" are the data values,
= connects/assigns the data values to their corresponding variable names
Numeric Data Types: int, float, complex
int Represents integer numbers.
Examples:
x = 5
x is the variable name
= means assign the data value 5, to the variable name x
5 is the data value
myAge = 150
myAge is the variable name
= means assign the data value 150 to the variable name myAge
150 is the data value, notice that the value does NOT have decimals, it is
an integer
float Represents floating-point numbers.
y = 3.14
y is the variable name
= means assign the value 3.14 to the variable name y
3.14 is the data value, notice that the data value contains 2 decimal
numbers .14
complex Represents complex numbers.
z = 1 + 2j
Data structures are ways of organizing and storing data in a computer so
it can be used efficiently. They are fundamentals that help programmers
optimize their code and improve their applications performance. They
manage data in various ways.
Data Structures provides us with:
Efficiency:
A faster and more efficient data access, manipulation, and processing.
Organization:
A structured way to store and manage data, making it easier to work with.
Scalability:
Enable applications to handle large amounts of data and grow in size as
needed.
Code Optimization:
By choosing the right data structure, programmers can write more efficient
and effective code.
Problem Solving:
Tools for solving complex problems by modeling real-life scenarios,
organizing data in ways that makes it easier to analyze.
Examples of Data Structures:
Arrays:
Python does not have built-in support for Arrays, to work with arrays in
Python you will have to import a library, like the NumPy library
(https://numpy.org/).
Linked Lists:
Store elements in a sequential manner, where each element points to the next.
A Python linked list is an abstract data type in Python that allows users
to organize information in nodes, which then link to another node in the
list. This makes it easier to insert and remove information without
changing the index of other items in the list.
Stacks:
Follow a Last-In, First-Out (LIFO) principle.
Queues:
Follow a First-In, First-Out (FIFO) principle.
Trees:
Hierarchical data structures with nodes and edges, often used for
searching and organizing data.
Trees are non-linear data structures that store data hierarchically and
are made up of nodes connected by edges. For example, in a family tree, a
node would represent a person, and an edge would represent the
relationship between two nodes.
Graphs:
Model relationships between objects, used in routing, and other applications.
A graph is a data structure that consists of nodes (vertices) and edges. Edges connect pairs of nodes, they can be directed or undirected. Graphs are used to represent relationships between objects, such as maps, and computer networks.
Hash Tables:
Provide fast key-value lookup.
Some Key Concepts in Hash Tables are:
1) Abstract Data Types (ADTs): Logical models of data structures that define their behavior, but not their specific implementation.
2) Time Complexity: The efficiency of an algorithm in terms of how long it takes to run, often affected by the choice of data structure.
3) Space Complexity: The amount of memory an algorithm uses.
In essence, data structures are the building blocks of software, providing the foundation for organizing, storing, and managing data efficiently in computer programs.