☰
Python Across Disciplines
with Python + AI Tool   
×
Table of Contents

1.1.   Introduction 1.2.   About the Author & Contact Info 1.3.   Book Conventions 1.4.   What (Who) is a Programmer? 1.5.   Programming Across Disciplines 1.6.   Foundational Computing Concepts 1.7.   About Python 1.8.   First Steps 1.8.1 Computer Setup 1.8.2 Python print() Function 1.8.3 Comments
2.1. About Data 2.2. Data Types 2.3. Variables 2.4. User Input 2.5. Data Structures (DS)         2.5.1. DS Concepts         2.5.2. Lists         2.5.3. Dictionaries         2.5.4. Others 2.6. Files         2.6.1. Files & File Systems         2.6.2. Python File Object         2.6.3. Data Files 2.7. Databases
3.1. About Processing 3.2. Decisions         3.2.1 Decision Concepts         3.2.2 Conditions & Booleans         3.2.3 if Statements         3.2.4 if-else Statements         3.2.5 if-elif-else Statements         3.2.6 In-Line if Statements 3.3. Repetition (a.k.a. Loops)         3.3.1  Repetition Concepts         3.3.2  while Loops         3.3.3  for Loops         3.3.4  Nested Loops         3.3.5  Validating User Input 3.4. Functions         3.4.1  Function Concepts         3.4.2  Built-In Functions         3.4.3  Programmer Defined Functions 3.5. Libraries         3.5.1  Library Concepts         3.5.2  Standard Library         3.5.3  External Libraries 3.6. Processing Case Studies         3.6.1  Case Studies         3.6.2  Parsing Data
4.1. About Output 4.2. Advanced Printing 4.3. Data Visualization   4.4  Sound
  4.5  Graphics
  4.6  Video
  4.7  Web Output
  4.8  PDFs & Documents
  4.9  Dashboards
  4.10  Animation & Games
  4.11  Text to Speech

5.1 About Disciplines 5.2 Accounting 5.3 Architecture 5.4 Art 5.5 Artificial Intelligence (AI) 5.6 Autonomous Vehicles 5.7 Bioinformatics 5.8 Biology 5.9 Bitcoin 5.10 Blockchain 5.11 Business 5.12 Business Analytics 5.13 Chemistry 5.14 Communication 5.15 Computational Photography 5.16 Computer Science 5.17 Creative Writing 5.18 Cryptocurrency 5.19 Cultural Studies 5.20 Data Analytics 5.21 Data Engineering 5.22 Data Science 5.23 Data Visualization 5.24 Drone Piloting 5.25 Economics 5.26 Education 5.27 Engineering 5.28 English 5.29 Entrepreneurship 5.30 Environmental Studies 5.31 Exercise Science 5.32 Film 5.33 Finance 5.34 Gaming 5.35 Gender Studies 5.36 Genetics 5.37 Geography 5.38 Geology 5.39 Geospatial Analysis ☯ 5.40 History 5.41 Humanities 5.42 Information Systems 5.43 Languages 5.44 Law 5.45 Linguistics 5.46 Literature 5.47 Machine Learning 5.48 Management 5.49 Marketing 5.50 Mathematics 5.51 Medicine 5.52 Military 5.53 Model Railroading 5.54 Music 5.55 Natural Language Processing (NLP) 5.56 Network Analysis 5.57 Neural Networks 5.58 Neurology 5.59 Nursing 5.60 Pharmacology 5.61 Philosophy 5.62 Physiology 5.63 Politics 5.64 Psychiatry 5.65 Psychology 5.66 Real Estate 5.67 Recreation 5.68 Remote Control (RC) Vehicles 5.69 Rhetoric 5.70 Science 5.71 Sociology 5.72 Sports 5.73 Stock Trading 5.74 Text Mining 5.75 Weather 5.76 Writing
6.1. Databases         6.1.1 Overview of Databases         6.1.2 SQLite Databases         6.1.3 Querying a SQLite Database         6.1.4 CRUD Operations with SQLite         6.1.5 Connecting to Other Databases
Built-In Functions Conceptss Data Types Date & Time Format Codes Dictionary Methods Escape Sequences File Access Modes File Object Methods Python Keywords List Methods Operators Set Methods String Methods Tuple Methods Glossary Index Appendices   Software Install & Setup
  Coding Tools:
  A.  Python    B.  Google CoLaboratory    C.  Visual Studio Code    D.  PyCharm IDE    E.  Git    F.  GitHub 
  Database Tools:
  G.  SQLite Database    H.  MySQL Database 


Python Across Disciplines
by John Gordon © 2023

Table of Contents

Table of Contents  »  Chapter 2 : Data (Input) : Introduction to Data Structure (DS)

Introduction to Data Structures (DS)

Subscribe Contact


Contents

Overview

In programming, data structures are a way of organizing and storing data in a computer so that it can be accessed and modified efficiently. They define the physical form of the data (how it's stored in memory) and the set of operations that can be performed on it. Different data structures are suited to other kinds of applications, and the choice of a particular data structure can affect the efficiency of a program. The effective use of data structures can enhance the performance and scalability of software applications.

Concept: Data Structure
Full Concepts List: Alphabetical  or By Chapter 

In programming, data structures are specialized formats for organizing, processing, retrieving, and storing data. They provide the means to manage large amounts of data and are essential for designing efficient algorithms. Data structures are critical computing field and fundamental in the development of algorithms and the functioning of software systems. They are categorized broadly into linear data and non-linear. The choice of a data structure for a specific problem can profoundly impact on the efficiency of the solution, as each structure has its own set of strengths and weaknesses in terms of data access, processing speed, and memory usage. Understanding data structures and their applications is crucial for solving complex computational problems and effectively processing and storing data.

Data Structures

At an early stage of learning programming, variables and strings are the closest concepts you have learned so far to a data structure. These two concepts introduce the idea of storing data in memory while our programs run.

Variables, themselves, are not data structures. However, they are useful in understanding how we store data in memory. That is, as seen in Figure 1. we create a variable (label) and assign it a datum (value) using the assignment operator (=). The data value is stored in memory (Figure 2), and then we can access that data using the variable name. In code, it might look like this:

age = 25
print(age)


Figure 1: Variable assignment
Figure 1: Variables & Memory

Using variables to store and access a datum is foundational to programming. We often need to store and access more than one datum, though, and when those data are related in some way, then we'll use a data structure. We create a variable name (label) to identify data structures as well; the difference between this and the example in Figure 1 is that through the variable that points to a data structure, we can access more than one datum. An example of this that we have already worked with is a string.

In Python, a string is a data structure. Specifically, it's a sequence data structure that maintains a sequence of elements in a specific order. In the case of a string, these elements are characters. As we saw on Page 2.2.12 Strings , strings are a sequence of alphanumeric characters labeled with a variable name, as shown in Figure 3.




Figure 3: String data structure

In this example, the variable full_name is the label for the sequence of nine characters shown. We can use indexing and string slicing, like full_nanme[2], is because the string is a data structure. Python handles storing the set of characters that make up this string so that we can access any part of it through the variable name. This concept of having access to more than one data element in a string will carry us to the following data structures we will explore: lists and dictionaries.

Lists in Python are ordered collections of items that can be of any type. Unlike strings, lists are mutable, meaning their contents can be changed after they are created. They can be thought of as dynamic arrays, but with the added benefit of being able to hold different types of data.

Dictionaries in Python are unordered collections of items. Each item in a dictionary has a key/value pair. Dictionaries are optimized to retrieve values when the key is known. They are mutable, which means they can be changed after they are created.

We will explore lists and dictionaries on the following pages.



 





© 2023 John Gordon
Cascade Street Publishing, LLC