Programming Articles

Page 29 of 2547

How to Print the Last Word in a sentence using Python?

Nilesh Kumar
Nilesh Kumar
Updated on 27-Mar-2026 1K+ Views

Extracting the last word from a sentence is a common text processing task in Python. This can be accomplished using the split() method to break the sentence into words and accessing the last element. Using split() Method The split() method divides a string into a list of words, making it easy to access the last word using negative indexing. Syntax string.split(separator, maxsplit) Parameters: separator − Optional. Specifies the delimiter (default is whitespace) maxsplit − Optional. Maximum number of splits (default is -1 for all occurrences) Example def print_last_word(sentence): ...

Read More

Building Chatbots in Python

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 735 Views

A chatbot is a computer program designed to simulate conversations with human users via text or voice. It uses AI and NLP techniques to understand and interpret user messages and provide relevant responses. In this article, we will see how to create chatbots using Python. Chatbots like ChatGPT have become popular since the end of 2022 and have wide-scale use cases across different fields. They are integrated with mobile apps like Swiggy and Zomato to provide faster resolution to customer complaints. Types of Chatbots Rule-based chatbots − They respond to user input based ...

Read More

Modelling Two Dimensional Heat Conduction Problem using Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 3K+ Views

In this tutorial, we will see how to model the 2D heat conduction equation using Python. A 2D, steady-state heat conduction equation with heat generation can be written in Cartesian coordinates as follows − $$\mathrm{abla^{2} T \: + \: \frac{q_{g}}{k} \: = \: \frac{\partial^{2}T}{\partial x^{2}} \: + \: \frac{\partial^{2}T}{\partial y^{2}} \: + \: \frac{q_{g}}{k} \: = \: 0 \:\:\dotso\dotso (1)}$$ This equation must be discretized to obtain a finite difference equation. Let us consider a rectangular grid as shown below. ...

Read More

Modelling the Taylor Table Method in Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 554 Views

The Taylor Table method is an efficient technique for deriving finite difference schemes for derivatives using a specific stencil. A stencil is a collection of grid points used to approximate derivatives numerically. Understanding the Taylor Table Method Consider evaluating the second derivative using Taylor series expansions. For points around $x_i$: ...

Read More

Modelling Thermodynamic Entropy in Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 746 Views

Thermodynamic entropy is a fundamental property that measures the degree of randomness or disorder in a system. In Python, we can model entropy changes for various thermodynamic processes using mathematical formulations and create visualization tools. Understanding Entropy Entropy remains constant during a reversible adiabatic process. When a system exchanges dQ heat with its surroundings at temperature T, the entropy change is: ds = dQ/T ... (1) According to Clausius' inequality, the cyclic integral along any path satisfies: ∮(dQ/T) ≤ 0 ... (2) The equality holds for reversible processes, while inequality holds for irreversible cycles. ...

Read More

Modelling the Trapezoidal Rule for Numerical Integration in Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 2K+ Views

The purpose of definite integration is to calculate the area under a curve of a function between two limits, a and b. Numerical integration (also called quadrature) approximates this area by dividing it into simple geometric shapes. ...

Read More

Modelling Stirling and Ericsson Cycles in Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 408 Views

The Stirling cycle and Ericsson cycle are important thermodynamic cycles used in heat engines. Python provides excellent tools for modeling these cycles using matplotlib and pandas to visualize the pressure-volume relationships and calculate state properties. Stirling Cycle The Stirling cycle consists of four processes: two reversible isochoric (constant volume) and two reversible isothermal (constant temperature) processes. The ideal regenerative Stirling cycle has the same efficiency as the Carnot cycle in the same temperature range. ...

Read More

Finding the Summation of Random Numbers using Python

Kalyan Mishra
Kalyan Mishra
Updated on 27-Mar-2026 949 Views

In this article, we will learn different methods to find the summation of random numbers using Python. Whether you need to generate random numbers for testing, simulations, or statistical analysis, these approaches will help you calculate their sum efficiently. Let's explore various methods to generate random numbers and calculate their summation ? Using Simple Loop This method generates random numbers using a loop and stores them in a list before calculating the sum ? import random n = 10 rand_nums = [] for _ in range(n): rand_nums.append(random.randint(1, 100)) total ...

Read More

Queue.LIFOQueue vs Collections.Deque in Python

Kalyan Mishra
Kalyan Mishra
Updated on 27-Mar-2026 438 Views

In this article we will learn about Queue.LIFOQueue vs Collections.Deque in Python programming language. When we need to manage our data using the last in first out method, we can use these data structures. But to choose one of them we need to know about their functionalities and characteristics. Queue.LIFOQueue This class is part of the queue module. It works as a stack data structure and is thread-safe, meaning we can communicate between different threads simultaneously. Here are some key specifications: Stack-based − LIFOQueue behaves like a stack data structure where the item inserted last will ...

Read More

Modelling the Otto and Diesel Cycles in Python

Dr Pankaj Dumka
Dr Pankaj Dumka
Updated on 27-Mar-2026 753 Views

The Otto cycle and Diesel cycle are fundamental thermodynamic cycles used in internal combustion engines. Python provides powerful tools for modeling these cycles using mathematical equations and visualization libraries like matplotlib and pandas. Otto Cycle An air standard cycle called the Otto Cycle is employed in spark ignition (SI) engines. It comprises of two reversible adiabatic processes and two isochoric processes (constant volume), totaling four processes. When the work interactions take place in reversible adiabatic processes, the heat addition (2-3) and rejection (4-1) occur isochorically (3-4 and 1-2). ...

Read More
Showing 281–290 of 25,466 articles
« Prev 1 27 28 29 30 31 2547 Next »
Advertisements