Thursday, 3 December 2026

Build RAG Applications: Get Started

 



Learn RAG Fundamentals, LangChain, LlamaIndex, Python, Embeddings, and Gradio to Build Intelligent Generative AI Applications.

Generative AI has made it possible to build applications that can understand questions, generate content, and interact with users. However, large language models (LLMs) have one important limitation: they do not automatically know everything about your private documents, business data, or recently updated information.

How can we make AI applications answer questions using external documents and specific knowledge sources?

The answer is Retrieval-Augmented Generation (RAG).

RAG combines information retrieval with large language models. It allows an AI application to search for relevant information and use that information as context before generating a response.

The Build RAG Applications: Get Started course, offered by IBM on Coursera, introduces learners to the fundamentals of RAG and demonstrates how to build practical RAG-powered applications using Python, LangChain, LlamaIndex, and Gradio.

This intermediate-level course is particularly useful for Python developers, AI enthusiasts, and software engineers who want to move beyond basic chatbot development and start building knowledge-powered AI applications.

About the Build RAG Applications: Get Started Course

This course focuses on understanding how RAG works and how its components can be combined to develop useful generative AI applications.

You will begin with RAG fundamentals, explore how retrieval pipelines connect with language models, and then develop applications that answer questions using information contained in source documents.

The course also introduces two important frameworks:

  • LangChain: A framework for connecting language models with prompts, retrieval systems, and application workflows.

  • LlamaIndex: A framework focused on connecting LLM applications with external data sources and building retrieval-based workflows.

You will also explore Gradio, which helps developers create interactive interfaces for AI applications.

According to Coursera, the course contains three modules, six assignments, and approximately seven hours of learning content.

What You Will Learn

The course focuses on four major learning outcomes.

Understand Retrieval-Augmented Generation

Develop a practical understanding of RAG, its architecture, and how retrieval improves information access in generative AI applications.

Build Interactive RAG Applications

Learn how to create user-friendly interfaces using Gradio and connect them with language models and retrieval pipelines.

Explore LangChain and LlamaIndex

Understand how these frameworks support RAG development and learn how their approaches differ.

Develop RAG Applications Using Python

Build practical applications using Python, LangChain, LlamaIndex, and language models.

Complete Course Breakdown

The course is divided into three modules that gradually introduce RAG concepts and practical implementation.

Introduction to RAG

<text color="secondary" size="xs" weight="medium">MODULE 1 · APPROXIMATELY 2 HOURS</text>

The first module introduces Retrieval-Augmented Generation and explains why it is important in modern generative AI applications.

You will examine the purpose and core principles of RAG and understand how its different components work together to retrieve relevant information.

The module also explores how a basic RAG workflow can support document summarization, conversational context, and question answering.

Important topics include:

  • What is Retrieval-Augmented Generation?

  • Why do AI applications need RAG?

  • Core principles of RAG architecture

  • Information retrieval

  • How retrieval and generation work together

  • Document summarization

  • Conversational context

  • Answering user queries using retrieved information

Practical activity: Summarize Private Documents Using RAG, LangChain, and LLMs

You will explore an application that uses RAG to summarize private documents. This demonstrates how an LLM can work with external document information instead of relying only on its pretrained knowledge.

The module includes video lessons, readings, practice quizzes, a graded quiz, and a hands-on application activity.

Build Apps with RAG

<text color="secondary" size="xs" weight="medium">MODULE 2 · APPROXIMATELY 2 HOURS</text>

The second module focuses on building interactive applications powered by RAG.

You will learn how a retrieval pipeline, a language model, and a user interface work together to create an AI application.

The module introduces Gradio, a Python framework for developing interactive interfaces for machine learning and generative AI applications.

Important topics include:

  • Components of a RAG application

  • Connecting language models with retrieval pipelines

  • Introduction to Gradio

  • Interactive AI interfaces

  • User input and model responses

  • Question-answering applications

  • Connecting loaded documents with an LLM

Practical Lab: Set Up a Simple Gradio Interface to Interact with Your Models

You will create a simple interface that allows users to interact with AI models without building a complete frontend from scratch.

Practical Lab: Construct a QA Bot Using LangChain and an LLM

This lab focuses on developing a question-answering bot that uses information from loaded documents.

The application demonstrates how users can ask questions and receive answers based on document content.

This module is particularly valuable for developers interested in creating document assistants and knowledge-based chatbots.

Build RAG Apps with LlamaIndex

<text color="secondary" size="xs" weight="medium">MODULE 3 · APPROXIMATELY 2 HOURS</text>

The final module introduces LlamaIndex and explains how it can be used to develop RAG applications.

You will explore how LlamaIndex handles document ingestion, chunking, vector stores, retrievers, and query engines.

The module also compares LlamaIndex with LangChain, helping learners understand how the two frameworks approach RAG application development.

Important topics include:

  • Introduction to LlamaIndex

  • Document ingestion

  • Document chunking

  • Embeddings

  • Vector databases

  • Vector stores

  • Retrievers

  • Query engines

  • Prompt templates

  • Conversational RAG applications

  • LangChain versus LlamaIndex

Practical Lab: Build an AI Icebreaker Bot with LlamaIndex and IBM Granite

You will work with LlamaIndex and IBM Granite to build an interactive AI application.

This project demonstrates how a language model can be combined with a retrieval-oriented framework to create an application with more context-aware responses.

The module includes video lessons, readings, practice and graded quizzes, and a hands-on lab.

Technologies and Tools Covered

The course introduces several important technologies used in modern RAG development.

TechnologyPurpose
PythonDeveloping AI applications
LangChainConnecting LLMs with retrieval workflows
LlamaIndexBuilding data-connected AI applications
GradioCreating interactive AI interfaces
IBM GraniteWorking with generative AI models
EmbeddingsRepresenting text as numerical vectors
Vector DatabasesStoring and retrieving vector representations
Large Language ModelsGenerating context-aware responses

Understanding RAG Architecture

Retrieval-Augmented Generation works by combining an information retrieval system with a language model.

A typical RAG application follows a sequence of steps.

Document Collection

The application receives information from documents, PDFs, text files, or other knowledge sources.

Document Processing

The documents are prepared and divided into smaller sections called chunks.

Embedding Generation

An embedding model converts the text into numerical vector representations.

Information Storage

The embeddings and associated document information are stored in a searchable data store.

User Query

A user asks a question through the application interface.

Information Retrieval

The system searches for relevant document sections using the user's query.

Context-Based Generation

The retrieved information is provided to the language model as context.

Final Answer

The language model generates a response based on the question and retrieved information.

This approach helps applications answer questions using specific knowledge sources.

LangChain vs LlamaIndex

One important part of this course is understanding the difference between LangChain and LlamaIndex.

Both frameworks help developers build applications powered by large language models, but they emphasize different areas of development.

FeatureLangChainLlamaIndex
Main focusLLM application workflowsData-connected LLM applications
RAG supportYesYes
Common componentsChains, tools, retrieversData connectors, indexes, query engines
Document processingSupportedA major focus
Application developmentLLM workflows and integrationsData ingestion and retrieval workflows
Typical useBuilding connected AI applicationsBuilding knowledge-based AI applications

Understanding both frameworks gives developers more flexibility when selecting tools for different RAG projects.

What Is Gradio and Why Is It Useful?

Gradio is a Python framework that allows developers to create interactive interfaces for machine learning models and AI applications.

Instead of building a frontend using HTML, CSS, and JavaScript, developers can use Python to create interfaces for users to interact with their models.

For example, imagine creating a document question-answering application.

A user uploads a document, enters a question, and clicks a button. The application processes the document, retrieves relevant information, and displays the generated response.

Gradio makes it easier to create and demonstrate this type of application.

Common use cases include:

  • AI chat interfaces

  • Document question-answering systems

  • Text summarization applications

  • Image classification demos

  • Machine learning model demonstrations

  • Generative AI prototypes

Hands-On Projects and Practical Activities

The course includes practical application items that help learners understand how RAG concepts work in real applications.

Some of the listed activities include:

Summarize Private Documents Using RAG

Develop an understanding of how LangChain and language models can work with private documents to generate summaries.

Create an Interactive Gradio Interface

Build a simple interface that allows users to interact with AI models.

Build a Document Question-Answering Bot

Create a QA bot that uses loaded documents to answer user questions through a LangChain-based workflow.

Build an AI Icebreaker Bot

Use LlamaIndex and IBM Granite to develop an interactive AI application.

These activities provide practical exposure to document processing, retrieval, language models, and user interfaces.

Real-World Applications of RAG

RAG can be used in many industries because it allows AI applications to work with external and domain-specific information.

Document Question-Answering Systems

Users can upload documents and ask questions about their contents.

Customer Support Chatbots

Businesses can connect AI assistants to product manuals, FAQs, and support documentation.

Educational AI Assistants

Students can ask questions about textbooks, lecture notes, and course materials.

Enterprise Knowledge Assistants

Employees can search internal company documents using natural language.

Research Assistants

Researchers can retrieve relevant information from large collections of articles and documents.

Document Summarization

AI applications can summarize lengthy reports, policies, and research documents.

Personal Knowledge Assistants

Users can create assistants that answer questions using their own notes and files.

Who Should Take This Course?

This course is suitable for learners who want to understand RAG and develop practical generative AI applications.

It can be useful for:

  • Python developers

  • Software engineers

  • AI and machine learning enthusiasts

  • Data scientists

  • Generative AI developers

  • Students interested in AI engineering

  • Developers building AI chatbots

  • Professionals exploring LLM application development

Recommended background: Coursera classifies this course as intermediate level and recommends prior experience. A working knowledge of Python and basic familiarity with AI concepts will make the practical activities easier to follow.

Skills You Can Develop

After completing the course, learners can develop practical knowledge of:

  • Retrieval-Augmented Generation

  • Generative AI application development

  • Python-based AI workflows

  • LangChain

  • LlamaIndex

  • Prompt templates

  • Embeddings

  • Vector databases

  • Document ingestion

  • Document chunking

  • Information retrieval

  • Question-answering systems

  • Gradio interfaces

  • IBM Granite

  • Context-aware AI applications


Join Now:Build RAG Applications: Get Started

Final Verdict

The Build RAG Applications: Get Started course is a useful introduction for developers who want to move from basic generative AI concepts to practical RAG application development.

Its three-module structure provides a clear learning path: understand RAG fundamentals, build an interactive application with Gradio and LangChain, and explore LlamaIndex as another framework for developing retrieval-based applications.

The practical activities are particularly valuable because they include private document summarization, document question answering, and an AI Icebreaker Bot using IBM Granite.

If you already have Python knowledge and want to start building AI applications that can retrieve information from documents, this course is worth exploring.


๐Ÿ Python Pattern Challenge — Day 57

 



๐Ÿ Python Pattern Challenge — Day 57 | Double Wing Star Pattern

Welcome to Day 57 of the Python Pattern Challenge! ๐Ÿš€

Today, we're creating a creative Double Wing Star Pattern using Python.

This pattern consists of two symmetrical star structures facing each other. The stars gradually change their positions in every row, creating an interesting butterfly-like geometric design.

The challenge is to arrange stars and spaces carefully while maintaining symmetry throughout the pattern.

This exercise is perfect for practicing loops, string manipulation, spacing, and logical thinking.

๐ŸŽฏ Today's Challenge

Write a Python program to print exactly the following pattern:


๐Ÿ’ป Python Solution

pattern = [ "** **", "**** ****", "** ** ** **", "** ** ** **", "** *** **", "** ** ** **", "** ** ** **", "**** ****", "** **" ] for row in pattern: print(row)







๐Ÿง  Understanding the Logic

1. Creating the pattern

pattern = [...]


A Python list stores each row of the design as a separate string.

2. Understanding star placement

Each row contains two groups of stars. Their arrangement changes to create the wing-like structure.

3. Managing spaces

Spaces between the star groups control the distance between the two sides and help maintain the overall design.

4. Using a for loop

for row in pattern:

The loop iterates through every row stored in the list.


5. Printing the final design

print(row)

๐Ÿš€ Challenge Yourself

  • Increase the width of the pattern.

  • Replace stars with numbers or alphabets.

  • Create a butterfly-shaped variation.

  • Try generating the same pattern using nested loops.

  • Experiment with different star arrangements.

๐Ÿ’ก What Will You Learn?

By completing this challenge, you will practice:

  • Python lists and strings

  • For loops

  • String manipulation

  • Pattern alignment

  • Character positioning

  • Logical problem-solving

๐ŸŽฏ Final Thoughts

Python pattern printing is a fun way to improve your programming fundamentals. It teaches you how to arrange characters, control spaces, and create symmetrical designs using simple Python concepts.

Don't just copy the patterns — try understanding the logic behind every row and create your own designs!

57 Days. 57 Patterns. Stronger Python Logic! ๐Ÿ๐Ÿ”ฅ


Wednesday, 2 December 2026

Python Coding Challenge - Question with Answer (ID 031226)

 


Explanation:

Step 1: Understanding Boolean Values
[True, False, True, True]

Python treats Boolean values as integers during arithmetic operations.
- True = 1
- False = 0
Therefore, the list behaves like:
[1, 0, 1, 1]


Step 2: Understanding the sum() Function
sum([True, False, True, True])

The sum() function adds all the elements of an iterable.

Calculation:
\[
1 + 0 + 1 + 1 = 3
\]

So the result is:
3

Step 3: Understanding Multiplication
3 * 2

After calculating the sum, Python multiplies the result by 2.
\[
3 \times 2 = 6
\]

Step 4: Understanding the Complete Statement
print(sum([True, False, True, True]) * 2)

Execution order:
1. Python evaluates the list.
2. True and False behave as 1 and 0.
3. sum() calculates the total: 3.
4. Python multiplies 3 by 2.
5. print() displays 6.

Final Output:

6

Books: Numerical Python for Astronomy and Astrophysics

Python Zero to Hero: Learn Python Step-by-Step by Creating Apps, Automating Tasks, and Solving Everyday Problems (The Python Hero Series Book 1)

 


Introduction

Learning Python becomes much easier when you move beyond memorizing syntax and start creating things with code.

Imagine writing a program that organizes your files automatically, building a small application to manage daily tasks, or creating a tool that solves a repetitive problem. These are the kinds of practical experiences that make programming exciting and useful.

Python Zero to Hero: Learn Python Step-by-Step by Creating Apps, Automating Tasks, and Solving Everyday Problems is presented as the first book in The Python Hero Series. Its central theme is learning Python through practical applications rather than focusing only on programming theory.

The book's title highlights three important learning goals: building applications, automating everyday activities, and developing problem-solving skills with Python.

For beginners who want to turn their programming knowledge into useful projects, this is an interesting book to explore.

Free Book: Python Zero to Hero: Learn Python Step-by-Step by Creating Apps, Automating Tasks, and Solving Everyday Problems (The Python Hero Series Book 1)

About the Book

This book focuses on taking readers from the basics of Python toward practical programming skills.

Python is widely used in automation, web development, data analysis, application development, artificial intelligence, and scripting. Its readable syntax makes it approachable for beginners, while its extensive ecosystem supports more advanced projects.

The practical approach suggested by this book encourages readers to understand programming concepts by applying them to real tasks.

Rather than learning a concept in isolation, readers can think about how it might be used to solve an everyday problem.

What You Can Expect to Learn

The following topics represent a learning roadmap based on the book's stated focus and title. They are not a verified chapter-by-chapter table of contents.

Python Fundamentals

Understand the basic building blocks of Python, including variables, data types, operators, expressions, and input/output operations.

Decision-Making and Loops

Learn how programs make decisions using conditional statements and repeat operations using loops.

Python Data Structures

Work with lists, tuples, sets, and dictionaries to organize and manage information efficiently.

Functions and Code Reusability

Understand how to create reusable functions, pass arguments, return results, and organize programs into smaller components.

File Handling

Learn how Python can read, write, and manage files, making it useful for handling everyday information and documents.

Exception Handling

Explore how to manage errors and unexpected situations so that programs can behave more reliably.

Practical Application Development

Apply Python fundamentals to create small programs and useful applications.

Task Automation

Discover how programming can reduce repetitive manual work and make everyday activities more efficient.

Learning Python Step by Step

A practical way to approach the subject is to build your knowledge progressively.

Understanding Python Basics

Start by learning how Python executes instructions and how different data types represent information.

For example:

name = "Python Hero" 
year = 2026 
print("Welcome to", name) 
print("Learning Year:", year)

This simple program introduces variables, strings, integers, and output statements.

Working with Conditions and Loops

Conditional statements allow programs to make decisions, while loops help repeat tasks.

tasks = ["Study Python", "Practice Coding", "Build an App"] 
for task in tasks: 
    print("Today's Task:", task)

This example demonstrates how a loop can process multiple items without writing the same instruction repeatedly.

Creating Reusable Functions

Functions help divide a program into smaller, manageable parts.

def calculate_total(price, quantity): 
       return price * quantity 
       total = calculate_total(250, 3) 
print("Total Amount:", total)

This example creates a reusable function for calculating the total cost of an item.

Build Practical Python Applications

One of the most interesting ideas behind the book is learning through application development.

Small applications help beginners understand how individual Python concepts work together.

Here are some project ideas that align with the book's practical theme.

Personal Expense Tracker

Create a program that records daily expenses, categorizes transactions, and calculates total spending.

Skills involved:

  • Variables and data types

  • Lists and dictionaries

  • Functions

  • File handling

To-Do List Application

Develop a simple task manager that allows users to add, view, update, and remove tasks.

Skills involved:

  • Lists

  • Conditional statements

  • Loops

  • Functions

Student Record Management System

Build a small program that stores student names, marks, and other details.

Skills involved:

  • Dictionaries

  • Data organization

  • Functions

  • File operations

Password Generator

Create a utility that generates random passwords using different combinations of characters.

Skills involved:

  • Strings

  • Loops

  • Functions

  • Random number generation

File Organizer

Develop a script that sorts files into folders based on their extensions.

Skills involved:

  • File handling

  • Directory management

  • Conditional statements

  • Python's standard library

These are suggested practice projects based on the book's broad themes, not a confirmed list of projects included in the book.

Automating Everyday Tasks with Python

Automation is one of Python's most useful applications.

Many activities that require repetitive manual effort can be simplified through small scripts.

For example:

File Management

Automatically organize documents, images, and other files into separate folders.

Text Processing

Read text files, search for specific words, and extract useful information.

Spreadsheet Automation

Work with spreadsheet data and automate repetitive operations using suitable Python libraries.

Data Collection

Retrieve information from supported websites and APIs when permitted.

Daily Productivity

Create reminders, simple task trackers, and utilities that help manage everyday activities.

Python libraries such as os, pathlib, shutil, datetime, and csv can support many of these tasks.

Python Libraries Worth Exploring

As your Python skills grow, libraries can help you build more powerful applications.

LibraryCommon Use
os     Operating system operations
pathlib     File and directory paths
shutil     File management
random     Random number generation
datetime      Date and time operations
json      Working with JSON data
csv                      Reading and writing CSV files
tkinter      Building desktop interfaces
requests      Sending HTTP requests

These libraries provide useful starting points for automation and application-building projects. Their inclusion here is a supplementary learning recommendation, not a confirmed list from the book.

Why Learn Python Through Projects?

Project-based learning helps connect programming concepts with practical problems.

When you build an application, you need to think about more than syntax. You must understand the problem, organize the data, design the program's logic, handle errors, and test the final result.

This process helps develop several important programming abilities:

  • Logical thinking and problem-solving.

  • Writing reusable and organized code.

  • Understanding how different programming concepts work together.

  • Debugging errors and improving program reliability.

  • Developing confidence through practical implementation.

Who Should Read This Book?

Based on its stated beginner-oriented approach, the book may be suitable for:

  • Complete beginners who want to learn Python.

  • Students starting their programming journey.

  • Self-learners looking for practical coding experience.

  • Beginners interested in task automation.

  • Aspiring Python developers.

  • Readers who prefer building applications while learning programming.

It may also serve as a starting point for learners who eventually want to explore web development, data science, artificial intelligence, or software development.

Skills You Can Develop

By following a structured Python learning journey and practicing the concepts through projects, you can work toward developing:

  • Python programming fundamentals.

  • Conditional logic and loop-based programming.

  • Data structure handling.

  • Function-based programming.

  • File and directory operations.

  • Basic application development.

  • Task automation.

  • Debugging and problem-solving skills.

Your actual progress will depend on how consistently you practice and build projects alongside your reading.


Is Python Zero to Hero Worth Exploring?

For someone starting with Python, a practical learning approach can make programming more engaging.

The book's stated focus on building apps, automating tasks, and solving everyday problems gives beginners a clear direction: learn a concept, understand where it is useful, and practice applying it.

Its emphasis on practical programming is particularly relevant for learners who want to develop useful scripts instead of stopping after basic syntax exercises.

However, readers should remember that learning Python requires consistent coding practice. Reading alone is not enough. Try modifying examples, experimenting with different inputs, and building your own small applications.

Kindle: Python Zero to Hero: Learn Python Step-by-Step by Creating Apps, Automating Tasks, and Solving Everyday Problems (The Python Hero Series Book 1)

Hard Copy: Python Zero to Hero: Learn Python Step-by-Step by Creating Apps, Automating Tasks, and Solving Everyday Problems (The Python Hero Series Book 1)

Final Thoughts

Python Zero to Hero introduces an appealing approach to beginner programming: learn Python step by step and connect programming concepts with practical applications.

From understanding variables and functions to exploring automation and application development, this learning journey can help beginners develop a stronger foundation in Python.

If you are planning to start learning Python or want to improve your practical coding skills, this book is worth exploring as a potential starting resource.


Python Coding challenge - Day 1325| What is the output of the following Python Code?

 


Explanation:

1. Creating the Box Class

class Box:

- Defines a class named Box.

- This class represents a container that stores items.

- We will customize how its objects behave in Boolean conditions.


2. Defining the Constructor

def __init__(self, items):    self.items = items

- __init__() is a special method that runs automatically when an object is created.

- self refers to the current object.

- items receives a list passed during object creation.

- self.items = items stores that list inside the object.


3. Defining the __bool__() Method

def __bool__(self):    return len(self.items) > 2

- __bool__() is a special method that defines the truth value of an object.

- Python automatically calls it when we use bool() on the object or check it in an if condition.

- len(self.items) counts the number of items in the list.

- > 2 checks whether the list contains more than two elements.

- If the condition is true, the method returns True; otherwise, it returns False.


4. Creating the First Object

a = Box([1, 2])

- Creates an object named a.

- Passes the list [1, 2] to the constructor.

- The object stores two elements.

Its condition becomes:

len([1, 2]) > 22 > 2False


5. Creating the Second Object

b = Box([1, 2, 3])

- Creates another object named b.

- Passes [1, 2, 3] to the constructor.

- This object stores three elements.

Its condition becomes:

len([1, 2, 3]) > 23 > 2True


6. Checking the First Object

print(bool(a))

- bool() converts the object into a Boolean value.

- Python calls a.__bool__() automatically.

- The list contains only two elements.

- The condition 2 > 2 is false.

Result: False


7. Checking the Second Object

print(bool(b))

- Python calls b.__bool__() automatically.

- The list contains three elements.

- The condition 3 > 2 is true.

Result: True

Step-by-Step Execution

Object Items Length Condition Boolean result

a [1, 2] 2 2 > 2 False

b [1, 2, 3] 3 3 > 2 True


Final Output

False

True


Books: 500 Days Python Coding Challenges with Explanation

Tuesday, 1 December 2026

Python Coding Challenge - Question with Answer (ID 021226)

 






Explanation:

Step 1: Creating the Dictionary
d = {True: "A", 1: "B", 1.0: "C"}

Here, we are using three different-looking keys:
- True – Boolean value
- 1 – Integer value
- 1.0 – Float value
But Python has an interesting rule:
True == 1 == 1.0

Output:
True

All three values are equal, and they also have the same hash value.
hash(True) == hash(1) == hash(1.0)

Output:
True


Step 2: Understanding Dictionary Key Overwriting

Python dictionaries do not store duplicate keys when those keys are equal and have matching hash values.

Let's understand what happens internally:
Insertion Key Value Dictionary
1 True "A" {True: "A"}
2 1 "B" {True: "B"}
3 1.0 "C" {True: "C"}

Each new value replaces the previous value because the keys are considered equal.

Important: The original key object (True) remains in the dictionary, but its value gets updated to "C".

Step 3: Understanding len(d)
len(d)

- len() returns the number of key-value pairs.
- Since all three keys are treated as the same key, only one entry exists.
Output:
1


Step 4: Understanding d[True]
d[True]

- Python searches for the key True.
- The stored entry has the value "C".
- Therefore, it returns "C".

Step 5: Understanding the Complete Print Statement
print(len(d), d[True])

Execution:
1. len(d) returns 1.
2. d[True] returns "C".
3. print() displays both values separated by a space.

4. Final Output
1 C

Books: PYTHON LOOPS MASTERY

Design of Heuristic Algorithms for Hard Optimization: With Python Codes for the Travelling Salesman Problem (Graduate Texts in Operations Research)(Free PDF)

 



Design of Heuristic Algorithms for Hard Optimization – A Practical Guide to Metaheuristics with Python

Explore how heuristic algorithms solve difficult optimization problems using Python, with the Travelling Salesman Problem as a practical learning example.

Free  Book: Design of Heuristic Algorithms for Hard Optimization: With Python Codes for the Travelling Salesman Problem

Introduction

Many real-world problems involve finding the best possible solution from thousands or even millions of possible choices. Examples include planning delivery routes, scheduling jobs, managing transportation networks, assigning resources, and optimizing production systems.

Finding an optimal solution is not always easy. Some optimization problems become extremely difficult as the number of variables and possible combinations increases. This is where heuristic algorithms and metaheuristics become useful.


About the Book

The book focuses on designing heuristic algorithms for difficult optimization problems. Instead of presenting metaheuristics as complicated, unrelated techniques, the author breaks them down into fundamental ideas such as construction, improvement, decomposition, randomization, and learning.

The Travelling Salesman Problem provides a practical foundation throughout the book. It asks a simple question: given a set of cities and the distances between them, what is the shortest possible route that visits every city once and returns to the starting city?

Although the question sounds simple, finding the best route becomes increasingly difficult as the number of cities grows.

The book demonstrates how different heuristic strategies can help find good solutions without necessarily examining every possible route.

What You Will Learn

The book develops several important areas of optimization and algorithm design.

Combinatorial Optimization

Understand problems in which the goal is to select the best solution from a large number of possible combinations. You will explore how constraints, variables, and objective functions define an optimization problem.

Graph Theory and Complexity

Learn how graphs represent relationships between objects and how complexity theory helps identify computationally difficult problems.

Heuristic Algorithms

Understand practical methods that search for good solutions efficiently when finding an exact optimum may be too expensive.

Local Search

Explore how an existing solution can be improved by making small changes and comparing the results.

Metaheuristics

Study broader algorithmic strategies that combine different search techniques to explore large solution spaces.

Python Implementation

See how optimization methods can be translated into short Python programs, using the Travelling Salesman Problem as a common application.

Detailed Chapter-Wise Breakdown

The book is organized into three main technical parts, followed by supporting material.

Combinatorial Optimization, Complexity Theory, and Problem Modelling

This section builds the theoretical foundation needed to understand difficult optimization problems.

Elements of Graphs and Complexity Theory

Learn the basics of graph theory and computational complexity. Graphs provide a natural way to represent cities, connections, routes, and networks.

The chapter also explains why it is important to determine whether a problem can be solved efficiently using an exact algorithm before designing a heuristic approach.

A Short List of Combinatorial Optimization Problems

Explore examples of combinatorial optimization problems and understand how different real-world situations can be expressed as mathematical optimization tasks.

Problem Modeling

Learn how to represent a problem through its data, constraints, and objectives. The chapter also introduces transformations and multi-objective optimization concepts.

Basic Heuristic Techniques

This section introduces the fundamental methods used to construct and improve solutions.

Constructive Methods

Understand how to build a solution step by step. In a route-planning problem, for example, a constructive method can select the next city based on a particular rule until a complete route is formed.

Local Search

Learn how to improve an existing solution by exploring nearby alternatives. In the TSP, this could involve changing the order in which cities are visited and checking whether the new route is shorter.

Decomposition Methods

Explore how a difficult optimization problem can be divided into smaller, more manageable subproblems. The chapter also introduces recursive constructive methods, Large Neighborhood Search, and POPMUSIC.

Popular Metaheuristics

This section explains the major ideas behind modern heuristic search strategies.

Randomized Methods

Understand how randomness can help algorithms explore different solutions and avoid becoming trapped in unproductive search areas.

Construction Learning

Explore methods that use information gathered during the search process to guide the construction of better solutions.

Local Search Learning

Learn how search strategies can adapt based on the performance of previous improvements.

Population Management

Understand approaches that maintain and manage multiple candidate solutions instead of working with only one solution at a time.

Heuristics Design

Learn how to develop a heuristic for a particular problem, divide complex problems into smaller tasks, tune algorithm parameters, and compare algorithm performance.

Codes

The final technical chapter provides utility programs and implementations for testing different metaheuristics. These include random-number generation, TSP data structures, and code for evaluating and comparing tours.

The book's official table of contents lists these chapters and their page ranges.


Important Optimization Techniques Explained

Constructive Heuristics

These algorithms create a complete solution from smaller decisions. They are useful when a problem has many possible combinations and a quick initial solution is needed.

Local Search Algorithms

Local search starts with an existing solution and tries to improve it through small modifications. It is especially useful for route optimization, scheduling, and assignment problems.

Randomized Search

Randomization introduces controlled variation into the search process. It can help explore different regions of the solution space.

Large Neighborhood Search

This technique modifies a larger portion of an existing solution before rebuilding or improving it. It can help escape situations where small changes are insufficient.

Population-Based Methods

Rather than maintaining one candidate solution, population-based strategies work with multiple solutions and manage how they evolve or are selected.

Python Codes and Practical Implementation

The book includes short Python programs to demonstrate the ideas discussed in its chapters. These implementations are intended to make the algorithmic procedures concrete and easier to experiment with.

The code material includes utilities for:

  • Generating random numbers and permutations.

  • Representing Travelling Salesman Problem data.

  • Calculating the length of a tour.

  • Transforming route representations.

  • Comparing different tours.

  • Testing complete metaheuristic procedures.

The author also provides supplementary Python code resources. The examples are deliberately compact, so readers can focus on understanding the core algorithmic ideas rather than depending on large programming frameworks.

Real-World Applications

The techniques discussed in the book are relevant to several practical domains.

Transportation and Logistics

Finding efficient delivery routes, reducing travel distances, and improving distribution planning.

Production Scheduling

Organizing manufacturing tasks and deciding how resources should be allocated.

Supply Chain Optimization

Improving transportation networks, inventory decisions, and distribution strategies.

Network Optimization

Finding efficient paths and improving the structure or operation of connected systems.

Operations Research

Developing mathematical and computational approaches to complex planning and decision-making problems.

These are broader application areas for heuristic optimization; the book uses TSP and other combinatorial problems to explain the underlying methods.

Who Should Read This Book?

This book can be useful for:

  • Computer science and engineering students.

  • Data science and operations research learners.

  • Python programmers interested in algorithm design.

  • Researchers studying combinatorial optimization.

  • Developers working on scheduling and routing problems.

  • Students interested in artificial intelligence and metaheuristics.

Readers do not need extensive prior knowledge of combinatorial optimization to begin following the material. However, familiarity with basic Python programming, algorithms, and mathematical reasoning will make the learning experience easier.

Skills You Can Develop

After studying the concepts and experimenting with the code examples, readers can develop skills in:

  • Understanding combinatorial optimization problems.

  • Applying graph theory to practical problems.

  • Designing constructive heuristic algorithms.

  • Improving solutions through local search.

  • Understanding randomized and population-based methods.

  • Implementing optimization techniques in Python.

  • Evaluating and comparing algorithm performance.

  • Breaking complex optimization problems into smaller tasks.


Is This Book Worth Reading?

If you are interested in understanding how optimization algorithms work beyond basic sorting and searching, this book offers a valuable learning resource.

Its strongest feature is the way it connects theoretical concepts with practical algorithm design. The Travelling Salesman Problem makes it easier to visualize how different techniques construct, modify, and improve solutions.

It is particularly useful for readers who want to understand the reasoning behind heuristic algorithms rather than simply use an existing optimization library.

One thing to keep in mind is that the Python examples are concise and educational. They are designed to illustrate algorithmic principles, not necessarily to serve as production-ready software. 

Kindle:Design of Heuristic Algorithms for Hard Optimization: With Python Codes for the Travelling Salesman Problem (Graduate Texts in Operations Research)

Final Thoughts

Design of Heuristic Algorithms for Hard Optimization is a useful resource for anyone interested in Python-based algorithm design, operations research, and combinatorial optimization.

It introduces the foundations of difficult optimization problems and gradually explores constructive methods, local search, decomposition, randomized techniques, and metaheuristics.

For Python learners, it provides an opportunity to move beyond writing basic programs and start thinking about how algorithms can solve complex real-world problems.


AI Agents: From Logic to Autonomy: The Complete Guide to Building Intelligent AI Agents with Python, LangGraph, CrewAI, MCP, Multi-Agent Systems, and Real-World Automation (Free PDF)

 



Introduction

Artificial Intelligence is moving beyond traditional chatbots and simple question-answering systems. Modern AI applications can understand objectives, break tasks into smaller steps, retrieve information, interact with external tools, and coordinate multiple operations.

This development has introduced a new area of AI engineering known as Agentic AI.

AI agents combine large language models (LLMs), programming logic, memory, tools, and workflow orchestration to accomplish tasks with varying levels of autonomy.

AI Agents: From Logic to Autonomy: The Complete Guide to Building Intelligent AI Agents with Python, LangGraph, CrewAI, MCP, Multi-Agent Systems, and Real-World Automation by J. H. Rivers explores these concepts through a practical, development-focused approach.

The book is designed around moving from fundamental agent concepts toward building, testing, and deploying intelligent automation systems using modern Python technologies.

About the Book

The book introduces the idea that an AI system can do more than generate responses. It can use external tools, manage workflows, retrieve information, and perform actions based on a user's objective.

Its advertised coverage includes Python development, agent architecture, reasoning, planning, memory, Retrieval-Augmented Generation (RAG), LangGraph, CrewAI, Model Context Protocol (MCP), security, testing, and deployment.

This makes it relevant to developers who want to understand how modern AI agents are designed and how different technologies work together.

What You Will Learn

Fundamentals of AI Agents

An AI agent is a software system that can interpret a task, make decisions, and interact with its environment to achieve an objective.

A traditional chatbot generally responds to a prompt. An AI agent can perform multiple operations, evaluate intermediate results, and decide what to do next.

For example, consider an AI research assistant.

When asked to prepare a report, it might:

  • Understand the research objective.

  • Divide the task into smaller activities.

  • Search for relevant information.

  • Retrieve useful documents.

  • Analyze the collected information.

  • Prepare a structured report.

Understanding this difference is the first step toward developing autonomous AI applications.

Python Development for AI Agents

Python provides the programming foundation for building agentic applications.

Its libraries and integration capabilities make it possible to connect language models with APIs, databases, external services, and custom functions.

Important Python concepts for agent development include:

  • Functions and modules.

  • Classes and objects.

  • API integration.

  • Exception handling.

  • Asynchronous programming.

  • JSON data processing.

  • Environment variables.

  • External service integration.

These skills help developers build applications in which AI models can interact with real software systems.

Agent Architecture: Reasoning, Planning, and Decision-Making

Agent architecture defines how an AI system understands tasks and performs actions.

A typical agent architecture contains several components:

Reasoning: Interprets the user's request and determines what needs to happen.

Planning: Breaks a complex objective into smaller steps.

Tools: Provides access to external functions, APIs, and information sources.

Memory: Stores useful context and information from previous interactions.

Execution: Carries out selected actions.

Evaluation: Checks whether the results satisfy the original objective.

These components work together to create more capable AI applications.

Memory and Retrieval-Augmented Generation (RAG)

Memory allows agents to retain useful information across different stages of a task.

Without memory, an agent may lose important context during long conversations or complex workflows.

The book's advertised coverage includes persistent memory, semantic search, and knowledge retrieval.

RAG is particularly useful because it allows an AI application to retrieve relevant information from external documents or knowledge sources before generating a response.

A typical RAG workflow involves:

  • Collecting documents.

  • Splitting content into manageable sections.

  • Generating embeddings.

  • Storing embeddings in a vector database.

  • Retrieving relevant information.

  • Providing the retrieved context to an LLM.

This approach is useful for document assistants, knowledge-base applications, and enterprise information systems.

LangGraph: Building Stateful AI Workflows

<text weight="medium" color="default">LangGraph</text> is a framework for building stateful and controllable agent workflows.

It represents application logic through nodes and connections, allowing developers to organize complex processes into structured graphs.

Important concepts include:

  • Nodes and edges.

  • Shared workflow state.

  • Conditional routing.

  • Checkpointing.

  • Workflow persistence.

  • Human-in-the-loop interactions.

For example, a customer-support workflow could classify a request, retrieve relevant information, decide whether escalation is required, and route the task to the appropriate process.

LangGraph is especially useful when an application requires controlled execution, persistent state, and multiple decision points.

CrewAI: Collaborative Multi-Agent Systems

CrewAI focuses on building systems where multiple specialized agents collaborate.

Instead of asking one agent to perform every task, developers can assign different responsibilities to different agents.

Consider an automated research team:

  • A research agent gathers information.

  • An analysis agent examines the findings.

  • A verification agent checks important claims.

  • A writing agent prepares the final document.

CrewAI provides concepts for organizing agents around roles, goals, tasks, and collaboration.

This approach can make complex workflows easier to divide into specialized responsibilities.

Model Context Protocol (MCP)

The Model Context Protocol, commonly known as MCP, provides a standardized way for AI applications to connect with external tools and data sources.

It helps reduce the need for building completely separate integration methods for every application.

MCP introduces three important components:

MCP Host: The AI application that uses MCP capabilities.

MCP Client: The component that communicates with an MCP server.

MCP Server: The service that exposes tools, resources, and other capabilities.

For example, an AI assistant could use an MCP server to access approved files, retrieve database information, or interact with an external application.

Understanding MCP is increasingly valuable for developers building interoperable AI systems.

Multi-Agent Systems and Collaboration

Multi-agent systems involve multiple AI agents working together to solve complex problems.

Each agent can have a specialized role, specific tools, and its own responsibilities.

A well-designed multi-agent system may include a coordinator that assigns tasks, manages communication, and combines results.

Common applications include:

  • Automated research teams.

  • AI-powered business assistants.

  • Software development workflows.

  • Data analysis systems.

  • Customer support automation.

  • Document processing pipelines.

However, adding more agents does not automatically improve a system. Developers must consider communication overhead, consistency, cost, and error handling.

Security, Testing, and Guardrails

AI agents can interact with external systems and perform actions, so security must be considered during development.

Important areas include:

  • Input validation.

  • Access control.

  • Tool permissions.

  • Prompt-injection awareness.

  • Sensitive information protection.

  • Output validation.

  • Execution limits.

  • Error handling.

Testing is equally important. Developers need to evaluate whether agents select appropriate tools, follow instructions, produce reliable results, and recover from failures.

Guardrails help prevent agents from performing actions outside their intended responsibilities.

Production Deployment and Automation

Developing an AI agent locally is only one stage of the engineering process.

Production deployment requires developers to consider application reliability, scalability, monitoring, and security.

The book's advertised coverage includes Docker, monitoring, and practical automation workflows.

Important production concepts include:

  • Containerizing applications.

  • Managing API credentials securely.

  • Configuring application environments.

  • Monitoring execution and errors.

  • Managing resource consumption.

  • Testing workflows.

  • Deploying services.

  • Maintaining application performance.

These practices help transform experimental AI agents into maintainable software applications.

Real-World Applications of AI Agents

Agentic systems can support a wide range of industries and technical workflows.

AI Research Assistants: Collect information, retrieve documents, compare findings, and prepare reports.

Customer Support Automation: Classify customer requests, retrieve relevant answers, and route complex cases.

Software Development Assistants: Analyze code, suggest improvements, assist with debugging, and support testing.

Data Analysis Agents: Retrieve information, execute calculations, interpret results, and generate summaries.

Business Process Automation: Coordinate document processing, database operations, and repetitive administrative tasks.

Personal Productivity Agents: Organize information, manage tasks, and interact with connected applications.

Technologies Covered and Related Tools

The book's title and description highlight several important technologies for modern AI engineering.

TechnologyMain purpose
PythonCore programming language
LangGraphStateful agent workflows
CrewAIMulti-agent collaboration
MCPStandardized tool connectivity
RAGKnowledge retrieval
DockerApplication containerization
Vector databasesSemantic information storage
LLM APIsLanguage-model integration

These technologies provide a foundation for developing intelligent applications that combine reasoning, retrieval, tools, and automation.

Who Should Read This Book?

This book may be suitable for:

  • Python developers interested in Agentic AI.

  • AI and machine learning enthusiasts.

  • Students exploring modern AI technologies.

  • Software engineers building LLM applications.

  • Developers interested in LangGraph and CrewAI.

  • Professionals exploring multi-agent automation.

  • Learners interested in MCP and production AI systems.

A basic understanding of Python programming and APIs will help readers follow the technical concepts more comfortably.

Skills You Can Develop

Studying the concepts covered in this book can help you develop skills in:

  • Understanding AI agent architecture.

  • Building Python-based AI applications.

  • Designing reasoning and planning workflows.

  • Implementing memory and RAG.

  • Creating stateful workflows with LangGraph.

  • Building collaborative agents with CrewAI.

  • Connecting external services through MCP.

  • Developing multi-agent systems.

  • Testing and securing agentic applications.

  • Deploying and monitoring AI automation systems.

Why Learning Agentic AI Matters

Traditional software generally follows instructions and workflows explicitly defined by developers.

Agentic AI introduces a different approach: language models can make decisions about which tools to use and how to proceed based on intermediate results.

This creates opportunities for more flexible automation, but it also introduces new engineering challenges.

Developers must understand how to balance autonomy with control, how to validate AI-generated decisions, and how to prevent unintended actions.

The goal is not simply to build an agent that can perform many tasks. It is to build one that performs the correct tasks reliably, securely, and within clearly defined boundaries.

What to Learn After This Book

After developing a foundation in agent architecture and orchestration, learners can explore more advanced topics:

  • Advanced Retrieval-Augmented Generation.

  • Agent evaluation and benchmarking.

  • LLM observability and tracing.

  • Human-in-the-loop automation.

  • Agent-to-Agent (A2A) communication.

  • Multimodal AI agents.

  • Computer-use agents.

  • Distributed AI systems.

  • AI safety and governance.

  • Scalable cloud deployment.

These areas can help developers progress toward building more sophisticated production AI systems.

Hard Copy:AI Agents: From Logic to Autonomy: The Complete Guide to Building Intelligent AI Agents with Python, LangGraph, CrewAI, MCP, Multi-Agent Systems, and Real-World Automation(Free PDF)

Kindle:AI Agents: From Logic to Autonomy: The Complete Guide to Building Intelligent AI Agents with Python, LangGraph, CrewAI, MCP, Multi-Agent Systems, and Real-World Automation(Free PDF)

Final Verdict

AI Agents: From Logic to Autonomy by J. H. Rivers is a practical learning resource for readers interested in understanding how intelligent AI agents are designed and developed.

Its advertised coverage brings together several important technologies, including Python, LangGraph, CrewAI, MCP, RAG, multi-agent systems, security, and production deployment.

The book's main appeal is its focus on moving beyond basic chatbot development toward intelligent applications that can use tools, retrieve information, collaborate, and automate workflows.

For Python developers and AI enthusiasts, these topics provide a useful direction for exploring the rapidly developing field of Agentic AI.



๐Ÿ Python Pattern Challenge — Day 56

 


๐Ÿ Python Pattern Challenge — Day 56 | Number Diamond Pyramid Pattern

Welcome to Day 56 of the Python Pattern Challenge! ๐Ÿš€

Today, we're creating a beautiful Number Diamond Pyramid Pattern using Python.

This pattern starts with the number 1 at the top and gradually expands toward the center. Each row contains increasing numbers followed by decreasing numbers, creating a symmetrical diamond shape.

After reaching the middle row, the pattern reverses and gradually shrinks until it ends with 1.

This challenge is perfect for improving your understanding of nested loops, number sequences, spacing, and mathematical logic.

๐ŸŽฏ Today's Challenge

Write a Python program to print exactly the following pattern:


๐Ÿ’ป Python Solution

n = 5 for i in range(1, n + 1): row = list(range(i, 2 * i)) row += list(range(2 * i - 2, i - 1, -1)) print(" " * (n - i) + " ".join(map(str, row))) for i in range(n - 1, 0, -1): row = list(range(i, 2 * i)) row += list(range(2 * i - 2, i - 1, -1)) print(" " * (n - i) + " ".join(map(str, row)))






๐Ÿง  Understanding the Logic

1. Define the pattern size

n = 5


This variable determines the maximum number of levels in the upper half of the diamond.

2. Generate increasing numbers

row = list(range(i, 2 * i))

This generates an increasing sequence of numbers for each row.

3. Generate decreasing numbers

row += list(range(2 * i - 2, i - 1, -1))

This adds the decreasing sequence, creating a symmetrical number arrangement.

4. Manage the spacing

" " * (n - i)

This adds leading spaces before each row to create the diamond shape.

5. Print the upper half

for i in range(1, n + 1):

The loop gradually increases the number of elements until it reaches the widest row.

6. Print the lower half

for i in range(n - 1, 0, -1):

The reverse loop recreates the same structure in decreasing order, completing the diamond.

๐Ÿš€ Challenge Yourself

  • Increase the maximum number from 9 to 11.

  • Replace numbers with alphabets.

  • Create an inverted number diamond.

  • Try generating the pattern using nested loops.

  • Experiment with different number sequences.

๐Ÿ’ก What Will You Learn?

By completing this challenge, you will practice:

  • Python for loops

  • range() function

  • List creation and concatenation

  • Number sequences

  • map() function

  • String formatting

  • Symmetrical pattern logic

๐ŸŽฏ Final Thoughts

Number patterns are an excellent way to improve your programming logic. They teach you how to combine mathematical sequences, loops, and spacing to create beautiful designs.

Keep practicing and challenge yourself with more complex Python patterns!

56 Days. 56 Patterns. Stronger Python Logic! ๐Ÿ๐Ÿ”ฅ

Learn • Practice • Grow with CLCODING


Popular Posts

Categories

100 Python Programs for Beginner (119) AI (366) Android (25) AngularJS (1) API (2) Assembly Language (2) aws (31) Azure (12) BI (10) book (1) Books (359) Bootcamp (21) C (78) C# (12) C++ (83) cloud (1) Course (98) Coursera (309) Cybersecurity (38) data (11) Data Analysis (48) Data Analytics (32) data management (17) Data Science (449) Data Strucures (22) Deep Learning (229) Django (17) Downloads (3) edx (21) Engineering (15) Euron (30) Events (9) Excel (24) Finance (13) flask (4) flutter (1) FPL (17) Gadgets (2) Generative AI (80) Git (14) Google (55) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (43) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (422) Meta (24) MICHIGAN (5) microsoft (14) Nvidia (8) Pandas (16) PHP (20) Projects (36) Python (1421) Python Bug (1) Python Coding Challenge (1323) Python Library (29) Python Mathematics (25) Python Mistakes (51) Python Pattern Challenge (53) Python Quiz (707) Python Tips (115) Python Turtle (3) Questions (3) R (72) RAG (4) React (7) Scripting (3) security (5) Selenium Webdriver (4) Software (21) SQL (57) Udemy (25) UX Research (1) web application (11) Web development (9) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)