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

Python Question

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)
2 views9 pages

Python Question

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
You are on page 1/ 9

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(t.count(2))
print(t.index(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.

You might also like