Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Python Articles
Page 699 of 855
Python Program for nth Catalan Number
In this article, we will learn about calculating the nth Catalan number using different approaches in Python. Catalan numbers are a sequence of natural numbers that occur in various combinatorial problems. They are defined by the recursive formula: C₀ = 1 and Cₙ₊₁ = Σᵢ₌₀ⁿ CᵢCₙ₋ᵢ for n ≥ 0 The first few Catalan numbers for n = 0, 1, 2, 3, ... are 1, 1, 2, 5, 14, 42, 132, 429, ... Catalan numbers can be calculated using recursion or dynamic programming. Let's explore both implementations. Approach 1: Recursive Method The recursive approach directly implements the mathematical definition ? # A recursive solution def catalan(n): # Base case if n
Read MorePython Program for How to check if a given number is a Fibonacci number?
In this article, we will learn how to check if a given number is a Fibonacci number using a mathematical property rather than generating the entire Fibonacci sequence. Problem Statement Given a number n, we need to determine whether n is a Fibonacci number or not. The Fibonacci sequence starts with 0 and 1, where each subsequent number is the sum of the previous two numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Mathematical Property A number is Fibonacci if and only if (5*n² + 4) or (5*n² - 4) is ...
Read MorePython Program for GCD of more than two (or array) numbers
In this article, we will learn how to find the Greatest Common Divisor (GCD) of more than two numbers or an array of numbers using Python. Problem statement − Given an array of numbers, we need to find the greatest common divisor of all elements. The GCD of multiple numbers can be calculated by repeatedly finding the GCD of pairs of numbers. We start with the first two numbers, find their GCD, then find the GCD of that result with the third number, and so on. Algorithm The approach involves: Implement a function to find ...
Read MorePython Program for the focal length of a spherical mirror
In this article, we will learn about calculating the focal length of a spherical mirror using Python. We'll explore both concave and convex mirrors with their respective formulas. Problem Statement We are given the radius of curvature of a spherical mirror and need to find its focal length. The focal length is the distance between the center of curvature of the mirror to the principal focus. To determine the focal length of a spherical mirror, we need to know its radius of curvature − the distance from the vertex of the mirror to the center of curvature. ...
Read MorePython Program for Finding the vertex, focus and directrix of a parabola
In this article, we will learn how to find the vertex, focus, and directrix of a parabola given its equation in standard form y = ax² + bx + c. Problem Statement Given a parabola equation in the standard form y = ax² + bx + c, we need to find: Vertex: The point where the parabola changes direction Focus: A fixed point inside the parabola Directrix: A fixed line outside the parabola ...
Read MorePython Program for Find the perimeter of a cylinder
In this article, we will learn how to calculate the perimeter of a cylinder using Python. The perimeter represents the outline of the cylinder when viewed from the side. Understanding Cylinder Perimeter When we view a cylinder from the side, it appears as a rectangle. The perimeter is the total distance around this rectangular outline. diameter (d) height (h) ...
Read MoreWindows 10 Toast Notifications with Python
We can create toast notifications for Windows 10 events using Python. This is very simple with the win10toast module. If you are familiar with Toast notifications in Android, then understanding toast notifications with Python is straightforward. We can generate notifications whenever an event occurs as a reminder. Installation Run the following command in command-line to install the win10toast module ? pip install win10toast If the module is successfully installed, you will get output similar to this ? Collecting win10toast Downloading https://files.pythonhosted.org/packages/d4/ba/95c0ea87d9bcad68b90d8cb130a313b939c88d8338a2fed7c11eaee972fe/win10toast-0.9-py2.py3-none-any.whl Collecting pypiwin32 (from win10toast) Installing collected packages: pypiwin32, win10toast Successfully installed ...
Read MoreWhat are the tools to support Data Science other than Python and R?
While Python and R dominate data science, numerous other powerful tools exist for data processing, storage, analysis, and machine learning. These tools complement programming languages and provide specialized capabilities for handling big data, distributed computing, and enterprise-scale analytics. Apache Hadoop Apache Hadoop is a Java-based open-source framework designed for distributed storage and processing of large datasets across clusters of computers. Key Features Distributed Storage − Uses Hadoop Distributed File System (HDFS) to store data across multiple nodes Fault Tolerance − Automatically handles hardware failures by replicating data Scalability − Can scale from single servers to ...
Read MoreK'th Non-repeating Character in Python using List Comprehension and OrderedDict
In this article, we will learn how to find the K'th non-repeating character in a string using Python's List Comprehension and OrderedDict. This approach maintains the order of first occurrence while efficiently counting character frequencies. Algorithm The algorithm follows these steps: 1. Create an OrderedDict from the input string to maintain insertion order 2. Count the frequency of each character by iterating through the string 3. Extract all characters that appear exactly once using list comprehension 4. Return the (k-1)th element from the non-repeating characters list Example Let's implement the solution to find ...
Read MoreIntroduction-to-convolutions-using-python
In this article, we will learn about convolutions in Python. Convolution is a fundamental operation in computer vision and neural networks for feature extraction from images. Prerequisites − NumPy, Matplotlib Installation pip install numpy pip install matplotlib What is Convolution? Convolution is a mathematical operation performed on an image to extract features by applying a smaller matrix called a kernel (or filter) that slides over the image like a window. Depending on the values in the kernel, we can detect specific patterns such as edges, corners, or textures. ...
Read More