Found 10784 Articles for Python

Building Chatbots in Python

Pranay Arora
Updated on 04-Oct-2023 14:02:39

256 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 help understand and interpret user’s messages and provide relevant responses. In this article, we will see how to create a chatbot with the help of Python. Chatbots like chatGPT have become popular since the end of 2022 and have a wide-scale use case for people of different fields. Chatbots are also integrated with mobile apps like Swiggy and Zomato to provide faster resolution to customer complaints. Chatbots are of multiple types which are as follows: ... Read More

Modelling Two Dimensional Heat Conduction Problem using Python

Dr Pankaj Dumka
Updated on 04-Oct-2023 11:28:48

1K+ Views

In this tutorial, we will see how to model 2D heat conduction equation using Python. A 2D, steady, heat conduction equation with heat generation can be written in Cartesian coordinates as follows − $$\mathrm{\triangledown^{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 has to be discretized to obtain a finite difference equation. Let us consider a rectangular grid as shown below. The index 𝑖 runs vertically i.e. row wise whereas the index 𝑗 runs horizontally i.e. column wise. Any inside node ... Read More

Modelling the Taylor Table Method in Python

Dr Pankaj Dumka
Updated on 04-Oct-2023 11:26:07

131 Views

The Taylor Table method is a very efficient and elegant method of obtaining a finite difference scheme for a particular derivative considering a specific stencil size. To understand it one should be very much clear about what is a stencil. Suppose one wants to evaluate $\mathrm{\frac{d^{2}f}{dx^{2}}}$ then in finite difference method the starting point is the Taylor series. Consider the figure shown below for a better understanding of the method. The Taylor series expansion at the point $\mathrm{x_{i} \: + \: h}$ will be: $$\mathrm{f(x_{i} \: + \: h) \: = \: f(x_{i}) \: + \: hf'(x_{i}) \: + ... Read More

Modelling Thermodynamic Entropy in Python

Dr Pankaj Dumka
Updated on 03-Oct-2023 15:16:27

236 Views

Entropy is a property of a thermodynamic system that remains constant during a reversible adiabatic process. Moreover, we can also say that it is the degree of randomness or disorder in the system. If a system exchanges dQ heat from its surroundings at temperature T, then the chance in the entropy can be written as − $$\mathrm{ds \: = \: \frac{dQ}{T} \dotso \dotso \: (1)}$$ According to Clausius' inequality the cyclic integral of $\mathrm{\frac{dQ}{T}}$ along a reversible path is either less or equal to zero. Mathematically, it can be written as − $$\mathrm{\oint\frac{dQ}{T} \: \leq \: 0\dotso \dotso \: (2)}$$ ... Read More

Modelling the Trapezoidal Rule for Numerical Integration in Python

Dr Pankaj Dumka
Updated on 03-Oct-2023 14:56:35

494 Views

The purpose of integration (definite) is to calculate the area under a curve of a function between two limits, a and b. The plot shown below will clear this concept further. Quadrature, which is also commonly called as numerical integration, is a method for evaluating the area under the curve of a given function. The process is very simple i.e. first we dividing the bounded area into several regions or strips. Thereafter, the areas is evaluated with the help of mathematical formula of simple rectangle. Then the area of all strips is added to obtain the gross area under ... Read More

Modelling Stirling and Ericsson Cycles in Python

Dr Pankaj Dumka
Updated on 03-Oct-2023 14:52:26

105 Views

Stirling Cycle Four processes—two reversible isochoric and two reversible isothermal—make up the Stirling cycle. In the same temperature range, the efficiency of the ideal regenerative Stirling cycle is equivalent to that of the Carnot cycle. Heat interaction takes place throughout the cycle, whereas work interaction only happens in processes 1-2 and 3–4. The figure shown below displays the cycle's schematic. Maximum pressure $\mathrm{(p_{max})}$, minimum pressure $\mathrm{(p_{min})}$, maximum volume $\mathrm{(v_{max})}$, compression ratio (r), and adiabatic exponent $\mathrm{(\gamma)}$ are the input variables taken into consideration when modelling the cycle. The following list includes the thermodynamic calculations of several processes involved in ... Read More

Finding the Summation of Random Numbers using Python

Kalyan Mishra
Updated on 03-Oct-2023 15:00:10

317 Views

In this article we will learn about different methods to find the Summation of Random Numbers using Python language. In some scenarios we need to generate some random number and find its summation so we will see basic to improved versions of functions using which we can get this task done. Let’s see some methods to find the summation of random numbers. Method 1. Using Simple Loop Example import random n = 10 rand_nums = [] for _ in range(n): rand_nums.append(random.randint(1, 100)) total = sum(rand_nums) print("Random Numbers:", rand_nums) print("Summation of random numbers:", total) Output Random Numbers: ... Read More

Queue.LIFOQueue vs Collections.Deque in Python

Kalyan Mishra
Updated on 03-Oct-2023 16:03:16

161 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 then we can use these data structures. But to choose one of them we need to know about their functionalities and characteristics. Before that let’s get to know about Queue.LIFOQueue and Collections.Deque. LIFOQueue This class is part of the queue module. It works as stack data structure and it is considered as thread safe means we can talk between the different threads at the same time. Here are some specifications of ... Read More

Modelling the Otto and Diesel Cycles in Python

Dr Pankaj Dumka
Updated on 03-Oct-2023 13:54:05

218 Views

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). The Otto cycle's schematic is shown in Figure given below. To model the cycle in Python, the input variables considered are maximum pressure $\mathrm{(P_{max})}$, minimum pressure $\mathrm{(P_{min})}$, maximum volume $\mathrm{(V_{max})}$, compression ratio (r), and adiabatic exponent $\mathrm{(\gamma)}$. Table 2 explains the thermodynamic computations of ... Read More

Python - Replace sublist with others in list

Kalyan Mishra
Updated on 03-Oct-2023 15:48:19

132 Views

In this article we will get to know how we can replace sublist value with new list. You may have faced this problem while working with manipulation of list. Here we will see various methods using which we can replace the sublist with other list. Let’s get to know this using below example − listItem = [1, 2, 3, 4, 5, 6] new_list = [7, 8, 9] Here we have list named as listItem which contains some elements and we have another list named as new_list. So, we want to replace the sublist of listItem with new_list. Take ... Read More

Advertisements