🔹 Python Fundamentals (1–15)
add = lambda a, b: a + b
print(add(2, 3)) # 5
1) What is Python?
Python is a high-level interpreted language used for 6) Explain *args and **kwargs
backend, automation, data, and AI.
Flexible arguments.
print("Hello Python") # Interpreted &
def demo(*args, **kwargs):
easy to write
print(args)
print(kwargs)
2) Difference between list and tuple? demo(1, 2, 3, name="Snehal")
# (1, 2, 3)
List is mutable, tuple is immutable. # {'name': 'Snehal'}
lst = [1, 2]
[Link](3)
print(lst) # [1, 2, 3] 7) Difference between shallow copy and
deep copy?
tup = (1, 2)
# [Link](3) # ❌ AttributeError Shallow copies reference nested objects, deep copies
duplicate everything.
import copy
3) What is a dictionary?
a = [[1, 2], [3, 4]]
A key-value data structure.
shallow = [Link](a)
d = {"name": "Snehal", "role": "GenAI
deep = [Link](a)
Dev"}
print(d["name"]) # Snehal
a[0].append(99)
print(shallow) # [[1, 2, 99], [3, 4]]
4) What is list comprehension? print(deep) # [[1, 2], [3, 4]]
One-line list creation.
nums = [1, 2, 3, 4] 8) What is exception handling?
squares = [n*n for n in nums]
print(squares) # [1, 4, 9, 16] Prevent crash using try/except.
try:
x = 10 / 0
5) What is a lambda function? except ZeroDivisionError:
print("Cannot divide by zero")
Anonymous one-line function.
9) What is a generator? def logger(func):
def wrapper():
Returns values lazily using yield. print("Before")
func()
def gen():
print("After")
yield 1
return wrapper
yield 2
@logger
g = gen()
def hello():
print(next(g)) # 1
print("Hello!")
print(next(g)) # 2
hello()
10) Difference between is and ==?
== compares value, is compares identity. 13) Mutable vs Immutable objects?
a = [1, 2] Lists are mutable, strings are immutable.
b = [1, 2]
s = "hi"
print(a == b) # True
# s[0] = "H" # ❌ TypeError
print(a is b) # False
lst = [1, 2]
lst[0] = 99
print(lst) # [99, 2]
11) What is GIL?
GIL prevents true CPU multi-threading in CPython.
14) What is slicing?
import threading
Extract part of a sequence.
def task():
arr = [10, 20, 30, 40, 50]
for _ in range(1000000):
print(arr[1:4]) # [20, 30, 40]
pass
print(arr[::-1]) # reverse
t1 = [Link](target=task)
t2 = [Link](target=task)
[Link](); [Link]() 15) What is init?
[Link](); [Link]()
Constructor called when object is created.
(Threads run but CPU-bound tasks won’t fully class User:
parallelize.) def __init__(self, name):
[Link] = name
u = User("Snehal")
12) What is a decorator?
print([Link])
Wrap a function without changing it.
🔹 OOP & Design 19) What is polymorphism?
Same method name, different behavior.
(16–25) class Cat:
def sound(self): return "meow"
16) What is OOP?
class Dog:
Code organized using classes/objects.
def sound(self): return "bark"
class Car:
def drive(self): for a in (Cat(), Dog()):
return "Driving..." print([Link]())
c = Car()
print([Link]())
20) What is abstraction?
Hide implementation, expose only essentials.
17) Four pillars of OOP? from abc import ABC, abstractmethod
Encapsulation, Inheritance, Polymorphism, Abstraction.
class Payment(ABC):
# quick example of inheritance + @abstractmethod
polymorphism def pay(self, amount):
class Animal: pass
def sound(self): return "sound"
class UPI(Payment):
class Dog(Animal): def pay(self, amount):
def sound(self): return "bark" return f"Paid {amount} via UPI"
print(Dog().sound()) # bark print(UPI().pay(100))
18) What is inheritance? 21) What is encapsulation?
Child inherits parent features. Restrict direct access to variables.
class Parent: class Account:
def show(self): def __init__(self):
return "Parent" self.__balance = 0 # private
class Child(Parent): def deposit(self, amt):
pass self.__balance += amt
print(Child().show()) # Parent def get_balance(self):
return self.__balance
acc = Account() 25) What are SOLID principles?
[Link](500)
Rules for clean OOP design.
print(acc.get_balance()) # 500
# Example of Single Responsibility:
class Report:
def generate(self):
22) What is method overriding?
return "report data"
Child redefines parent method.
class ReportPrinter:
class A: def print_report(self, report):
def show(self): return "A" print([Link]())
✅ Most Important
class B(A):
def show(self): return "B"
print(B().show()) # B
Concepts of Generative
AI (with Definitions)
23) What is a classmethod?
Works on class, uses cls. 1) Generative AI
class Demo: Generative AI is a type of AI that can create new
x = 10 content like text, images, code, audio, etc., based on
patterns learned from training data.
@classmethod
def update(cls, val):
cls.x = val
2) LLM (Large Language Model)
[Link](99) An LLM is a deep learning model trained on massive
print(Demo.x) # 99 text data to predict the next token, enabling it to
generate human-like text.
24) What is a staticmethod?
Utility method inside class.
3) Token
class Math: A token is the smallest unit an LLM processes (word,
part of a word, or punctuation).
@staticmethod
Token limits decide how much input + output a model
def add(a, b): can handle.
return a + b
print([Link](2, 3)) # 5
4) Prompt 10) Vector Database
A prompt is the input instruction given to an LLM to A vector database stores embeddings and enables fast
guide the response. similarity search.
It can include question, role, examples, and context. Examples: Pinecone, FAISS, Chroma, Weaviate.
5) Prompt Engineering 11) Similarity Search
Prompt engineering is the process of designing Similarity search finds the most relevant vectors to a
prompts to get accurate, safe, and structured outputs query vector using cosine similarity or dot product.
from an LLM. It is the retrieval step in RAG systems.
6) Temperature 12) RAG (Retrieval Augmented
Temperature controls randomness in LLM output.
Generation)
Low temperature → more deterministic answers.
RAG is a technique where the system retrieves relevant
High temperature → more creative but less reliable
documents from a knowledge base and gives them to
answers.
the LLM as context before generating an answer.
It reduces hallucination and supports private data.
7) Hallucination
A hallucination is when an LLM generates incorrect or
13) Chunking
fake information confidently.
Chunking means splitting large documents into smaller
It happens when the model lacks grounding or context.
pieces so they can be embedded and retrieved
effectively.
8) Context Window
The context window is the maximum number of tokens
14) Chunk Overlap
an LLM can process in one request (input + output).
Chunk overlap repeats a small part between chunks to
If exceeded, older text is dropped or truncated.
preserve context and avoid losing meaning at chunk
boundaries.
9) Embeddings
Embeddings are numerical vector representations of
15) Fine-tuning
text meaning.
Fine-tuning is retraining a pretrained model on a
They are used for semantic search, clustering,
custom dataset to change its behavior or improve
similarity matching, and RAG.
domain performance.
16) LoRA (Low Rank Adaptation)
LoRA is a parameter-efficient fine-tuning method where 23) Chain-of-Thought (CoT)
only small adapter layers are trained instead of updating
the full model. Chain-of-thought prompting encourages step-by-step
reasoning for better logical accuracy.
(Used carefully in production.)
17) QLoRA
QLoRA combines LoRA with quantization (usually 24) Agents
4-bit), making fine-tuning possible on smaller GPUs.
An agent is an LLM system that can decide actions
dynamically, such as calling tools, APIs, or search
systems to complete tasks.
18) Quantization
Quantization reduces model precision (FP16 → INT8
→ INT4) to reduce memory and speed up inference. 25) Tools / Function Calling
Tool calling allows an LLM to call external functions
(like calculator, DB query, weather API) and use results
19) Inference in answers.
Inference is the process of using a trained model to
generate output at runtime.
Latency and cost matter most here. 26) Memory (Chat Memory)
Memory stores conversation history or user context so
the chatbot can respond consistently across multiple
20) System Prompt turns.
A system prompt sets rules for the model (role, tone,
safety, constraints).
It is the strongest prompt instruction. 27) Guardrails
Guardrails are rules and safety layers that prevent
harmful, incorrect, or policy-violating output (especially
21) Few-shot Prompting important in medical/legal apps).
Few-shot prompting provides examples in the prompt
so the model learns the format and style from them.
28) Evaluation (LLM Eval)
LLM evaluation is measuring quality of outputs using:
22) Zero-shot Prompting
● faithfulness
Zero-shot prompting asks directly without examples.
Fast, but less accurate for structured tasks. ● relevance
● correctness
“When a user asks a question, the system retrieves only
● hallucination rate the most relevant document chunks instead of querying
GPT directly.”
● latency and cost
“I used LangChain to connect document retrieval with
an LLM, ensuring responses are grounded in the
uploaded document.”
“The model does not copy text verbatim; it understands
29) Grounding the context through embeddings and generates
responses based on learned document content.”
Grounding means forcing the LLM to answer using
trusted data (documents, DB, tools) instead of guessing.
“I built the application using Flask, containerized it with
Docker, and deployed it on AWS (EC2 + ECR) using
CI/CD pipelines.”
30) Prompt Injection “Environment variables and API keys were securely
managed to ensure compliance and data safety.”
Prompt injection is an attack where users try to
override system instructions (example: “Ignore previous R – Result
instructions…”).
Handled using strong prompts + input filtering + tool “The chatbot successfully generated answers only from
permissioning. the provided documents, not from GPT’s pre-trained
knowledge.”
S – Situation
“This ensured data security, accuracy, and compliance,
“In many organizations, especially in healthcare and which is critical for healthcare and enterprise
finance, sensitive information cannot be shared with environments.”
public AI tools like ChatGPT. The challenge was that
existing AI models relied on general pre-trained “The solution allows organizations to simply upload
knowledge and could not provide answers strictly based documents and instantly get accurate, domain-specific
on internal or proprietary documents, such as medical answers.”
guidelines or constitutional documents.”
“This approach demonstrates how Generative AI can be
T – Task safely and effectively used in real-world, sensitive data
scenarios.”
“My task was to build a secure, document-based
Generative AI chatbot that answers questions only
using the organization’s own data, not GPT’s general
knowledge. The solution needed to be accurate, TESTIN THE MODEL
scalable, and suitable for enterprise use where data I test GenAI systems at 3 levels: retrieval
privacy is critical.” quality, generation faithfulness, and end-to-end
performance.
A – Action I use regression datasets, hallucination checks,
groundedness evaluation, load testing, and
“I designed a Retrieval-Augmented Generation (RAG)
architecture using Python.” prompt-injection security testing.
“I ingested medical and policy documents, converted
them into embeddings, and stored them in a vector
database (Pinecone).”