0% found this document useful (0 votes)
5 views9 pages

Python Data Structures Overview

The document provides an overview of various data structures in Python, including lists, tuples, dictionaries, and sets, highlighting their characteristics and methods. It also discusses Large Language Models (LLMs) and their applications, along with an introduction to the Pandas library for data manipulation and analysis. Additionally, it covers the basics of machine learning, its types, and common algorithms.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

Python Data Structures Overview

The document provides an overview of various data structures in Python, including lists, tuples, dictionaries, and sets, highlighting their characteristics and methods. It also discusses Large Language Models (LLMs) and their applications, along with an introduction to the Pandas library for data manipulation and analysis. Additionally, it covers the basics of machine learning, its types, and common algorithms.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python

Lists :
In Python, a list is a built-in data type that is used to store collections
of items.

Lists are used to store multiple items in a single variable.

• Lists are mutable, ordered sequences of items.


• They are defined using square brackets [].
• Lists can contain elements of different data types.
• Elements in a list can be changed after creation.
• Lists are dynamic and can grow or shrink in size.
• Lists are commonly used for storing collections of items that
may need to be modified.

Methods
Method Description
Append() Adds an item to the end
extend() Adds all items from another list
insert() Inserts an item at a specific index
remove() Removes first matching value
pop() Removes item at given index (default last)
sort() Sorts the list (in-place)
reverse() Reverses the list (in-place)
index() Returns index of first matching value
count() Counts occurrences of a value
clear() Removes all items from the list
How do you create a list?

my_list = [1, 2, 3]
empty_list = []

Tuples :
A tuple is an immutable, ordered, and indexable collection of elements.
Once created, you cannot change its elements.

• Tuples are immutable, ordered sequences of items.


• They are defined using parentheses ().
• Tuples can contain elements of different data types.
• Elements in a tuple cannot be changed after creation.
• Tuples have a fixed size after creation.
• Tuples are generally faster than lists because of their
immutability.
• Tuples are commonly used for storing collections of items that
should not be modified.
method
print([Link](2))
print([Link](3))

Key Differences
Feature List Tuple

Mutability Mutable (changeable) Immutable (unchangeable)


Syntax [] ()

Size Dynamic Fixed

Performanc Slightly slower Faster

Use Case Changeable data Fixed data

Memory More memory intensive Less memory intensive

Dictionary:
In Python, a dictionary is a built-in data structure used to store collections of
data in key-value pairs. It allows for efficient retrieval of values based on
unique keys.

• A dictionary is a mutable, unordered collection of key-value pairs.


• Each key in a dictionary must be unique and immutable (like strings,
numbers, or tuples).
• In Python, a dictionary can be created by placing a sequence of
elements within curly {} braces, separated by a 'comma'.
• We can add new key-value pairs or update existing keys by using
assignment. eg :d["age"] = 22

What is the difference between a list and a dictionary?

Feature List Dictionary


Data
Ordered sequence Key-value pair
Structure
Access By index (e.g., list[0]) By key (e.g., dict["key"])
Syntax [1, 2, 3] {"a": 1, "b": 2}
Sets :
A set is an unordered, unindexed, mutable collection of unique elements.

Creating a Set

my_set = {1, 2, 3, 4}

empty_set = set()

LLM :
• A large language model is a type of artificial intelligence algorithm that
applies neural network techniques with lots of parameters to process
and understand human languages or text using self-supervised learning
techniques.
• There are many techniques that were tried to perform natural language-
related tasks but the LLM is purely based on the deep learning
methodologies.
• Large Language Models (LLMs) operate on the principles of deep
learning, leveraging neural network architectures to process and
understand human languages.
• Examples: of such LLM models are Chat GPT by open AI, BERT
(Bidirectional Encoder Representations from Transformers) by Google,
etc.
• LLM = Large Language Model
• They are powerful tools for working with human language in a wide
range of applications

What are LLMs used for?

LLMs can do many language-based tasks:

• Answering questions
• Translating languages
• Writing stories or code
• Summarizing text
• Chatbots

What are some examples of LLMs?

• GPT-4 / ChatGPT (by OpenAI)


• BERT (by Google)
• LLaMA (by Meta)

How are LLMs trained?

They are trained on huge text datasets (like books, websites, articles) using
machine learning to learn grammar, facts, reasoning, and context.

What language is used to work with LLMs?

Python is the most commonly used language to interact with and build on top
of LLMs.

How can I use an LLM in Python?

You can use libraries or APIs. Example using OpenAI API:

you use LLMs either through APIs or locally via libraries like transformers

What is the difference between GPT and LLM?

GPT (Generative Pretrained Transformer) is a type of LLM. So, all GPTs are
LLMs, but not all LLMs are GPTs.

Pandas :
• Pandas is open-source Python library which is used for data
manipulation and analysis.
• pandas is an extension of Python to process and manipulate tabular
data, implementing operations such as loading, aligning, merging, and
transforming datasets efficiently.
• It provides data structures like DataFrames (tabular data) and Series
(one-dimensional arrays) that make it easier to work with structured
data.

It helps you:

• Store data in tables (like Excel or SQL)


• Clean messy data
• Filter, sort, and analyze data easily
• Work with CSV, Excel, SQL, JSON, and more

What are the main data structures in Pandas?

• Series → One-dimensional (like a single column)


• DataFrame → Two-dimensional (like a full table)

How do you import Pandas in Python?

import pandas as pd

What is the command to install Pandas?

pip install pandas

OpenAI :
• OpenAI is a research organization and company that develops
advanced artificial intelligence (AI) systems — like chatGPT.
• OpenAI builds smart AI systems (like ChatGPT) that help people write,
learn, code, create images, and more — safely and responsibly.
• OpenAI is a research company that creates advanced AI tools to help
people with tasks like chatting, coding, writing, and more.

When was OpenAI founded?

OpenAI was founded in 2015.

Who were the founders of OpenAI?

Some key founders include:

• Elon Musk
• Sam Altman
• Greg Brockman
• Ilya Sutskever

What are some famous products of OpenAI?


ChatGPT
GPT-4

Whisper
copilot

Who is the current CEO of OpenAI?

As of 2025, it is Sam Altman (subject to change).


Machine Learning :
• Machine learning (ML) is a branch of artificial intelligence (AI) that
enables systems to learn from data, improve their performance, and
make predictions without being explicitly programmed.
• Machine Learning is teaching computers to learn from examples (data)
and improve over time.

Real-Life Examples of Machine Learning:

Use Case Example


Email Spam detection
Netflix Movie recommendations
Amazon Product suggestions
Voice
Recognizing your voice (like Siri, Alexa)
Assistants

What is the difference between classification and regression?

• Classification: Predicts categories (e.g., spam or not spam)


• Regression: Predicts continuous values (e.g., price of a house)

What are the types of Machine Learning?

1. Supervised Learning – learns from labeled data (e.g., regression,


classification)
2. Unsupervised Learning – finds patterns in unlabeled data (e.g.,
clustering)
3. Reinforcement Learning – learns by trial and error using rewards and
penalties

Which languages are used in ML?

Mostly:

• Python (most popular)


• R
• Java
• Julia

Common ML Algorithms:

• Linear Regression
• Decision Trees
• K-Nearest Neighbors (KNN)
• Support Vector Machines (SVM)
• Neural Networks

What is the difference between AI, ML, and Deep Learning?

Machine Learning = A subset of AI focusing on creating algorithms that learn from


data and make predictions.

Artificial Intelligence = Technology that enables machines to perform tasks that


typically require human intelligence.

Common questions

Powered by AI

Machine learning (ML) is a subset of artificial intelligence (AI) that focuses on creating algorithms that learn from data to make predictions or decisions without being explicitly programmed . Deep learning is a further subset of ML, involving neural networks with many layers for processing complex patterns in data . In contrast, artificial intelligence encompasses a broader range of technologies that enable machines to perform tasks requiring human-like intelligence, such as reasoning and problem-solving, incorporating both ML and deep learning as methods .

Pandas is preferred over basic Python data structures for data analysis because it offers flexible and powerful data frames and series for handling structured data in a tabular form, which facilitates better manipulation and analysis . Pandas' built-in functions for data loading, cleaning, filtering, and transformation simplify complex data operations that would otherwise require extensive coding if using traditional data structures like lists and dictionaries . Moreover, pandas can effortlessly handle large datasets and integrate with numerous data formats such as CSV, SQL, and JSON .

To interact with Large Language Models (LLMs) using Python, one typically employs libraries or APIs such as the OpenAI API for GPT models or the Transformers library for a wide range of LLMs . Python is the most common language for these tasks due to its extensive ecosystem of data science and machine learning packages, allowing seamless integration and model deployment. This interaction enables developers to leverage the extensive capabilities of LLMs, facilitating applications in automated content creation, natural language understanding, and conversational AI .

The primary differences between Python's list and tuple data structures are their mutability, syntax, and use cases. Lists are mutable, allowing their elements to be changed after creation, whereas tuples are immutable and cannot be changed once created . Lists are defined using square brackets [], while tuples use parentheses (). Due to their mutability, lists are suitable for collections of items that may need to be modified, while tuples are suited for storing fixed data collections . Tuples are generally faster and less memory-intensive than lists due to their immutability .

Python enables efficient data manipulation and transformation through its library pandas, which provides data structures like DataFrames for handling tabular data . Pandas simplifies complex data operations with built-in methods for aligning, merging, grouping, and filtering, leading to more intuitive data workflows than basic Python data structures . This capability is crucial for data cleaning, preprocessing, and ad-hoc analysis, allowing the transformation of raw data into structured formats suitable for further analysis or machine learning tasks . The integration with other data sources enhances its utility for data-oriented tasks .

Frequent machine learning algorithms used for classification tasks include decision trees, support vector machines (SVM), and k-nearest neighbors (KNN). Decision trees classify data by splitting it into branches based on feature values, culminating in a decision node for predictions . SVMs create a hyperplane that best distinguishes between categories in the feature space, optimizing for maximum margin between data points of different classes . KNN classifies data points based on the majority class of their nearest neighbors within the feature space .

Dictionaries and lists in Python serve different roles due to their structure and access methods. Lists are ordered sequences of items accessed by index, useful for storing collections that require ordered processing . Dictionaries, on the other hand, are unordered collections of key-value pairs, enabling efficient retrieval of values based on unique keys . This difference makes dictionaries better suited for representing data structures that require fast lookups by key, while lists are optimal for ordered data where sequential operations are necessary .

Large Language Models (LLMs) significantly impact natural language processing by leveraging deep learning and neural networks to understand and generate human languages. Their design, characterized by extensive training on large datasets, enables them to perform various language-related tasks such as answering questions, translating, and text summarization with remarkable accuracy . LLMs like GPT and BERT provide powerful tools for understanding context and semantics in text, thus advancing the capabilities of NLP applications like chatbots and automated text generation .

Choosing between supervised, unsupervised, and reinforcement learning requires understanding the nature of the available data and the project's goals. Supervised learning is suitable when labeled data is available, as it learns from input-output pairs to make predictions. It's ideal for tasks like regression and classification . Unsupervised learning is applied to unlabeled data, seeking to find inherent structures, such as clustering similar data points . Reinforcement learning is used when an agent needs to learn optimal actions via trial and error, guided by rewards — fitting for dynamic, decision-making environments . The choice depends on data structure, intended output, and the learning environment of the project.

OpenAI's advancements with models like GPT and ChatGPT have substantially enhanced conversational AI capabilities. These models leverage deep learning to generate human-like text, enabling sophisticated dialogue systems that understand and respond with contextually relevant information . They provide improved coherence, fluency, and adaptability in conversations, facilitating applications in customer service, virtual assistance, and personalized content generation. The pre-training on vast datasets allows them to retain and utilize a broad spectrum of knowledge, making interactions with AI systems more natural and effective .

You might also like