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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Find the number that appears once, and the other numbers twice in Python
Finding a unique number in a list that appears only once while all other numbers appear twice is a common programming problem. Python provides several approaches to solve this efficiently. The most efficient solution uses the XOR operator, which solves the problem in constant space and linear time complexity. In this article, we'll explore various methods to find the number that appears once while all others appear twice. Problem Understanding Given a list of numbers where every number appears exactly twice except one number that appears only once, we need to find that unique number ? ...
Read MorePython Program for Sum of first N even numbers
The sum of the first N even numbers is a mathematical operation where we add up the first N even numbers. In Python, there are multiple ways to calculate this sum. In this article, we will learn various approaches to finding the sum of the first N even numbers in Python. Understanding the Problem The first N even numbers form a sequence: 2, 4, 6, 8, 10, ... The mathematical formula for finding their sum is: Sum = N * (N + 1) Example: For N=5, the first 5 even numbers are: 2, 4, ...
Read MorePython Program to Calculate nCr and nPr
In combinatorics, nCr and nPr are essential formulas used to calculate combinations and permutations. They represent the number of ways to select and arrange objects from a set. nCr refers to combinations, where order does not matter, while nPr refers to permutations, where order does matter. The permutation refers to the arrangement of objects in a specific order. A combination refers to the selection of objects without taking order in reference. In this article, we are going to learn how we can calculate nCr and nPr in Python using different approaches. Formulas for nCr and nPr The ...
Read MorePython Program to find area of square
A square is a closed two-dimensional figure having 4 equal sides. Each angle of a square is 90 degrees. The area of a square is the space enclosed within its four sides. In this problem, we are given the side of a square, and we have to find the area of the square. In this tutorial, we are going to find the area of a given square in Python using different approaches. Formula The formula to calculate the area of a square is: Area = side × side = side² Examples Example 1 ...
Read MorePython Program for sum of the series: 1 + 1/2 + 1/3 + ... + 1/n
Mathematical series is one of the problems that helps us to improve problem-solving and logical thinking skills. One of the engaging problems is calculating the sum of the harmonic series. The series 1 + 1/2 + 1/3 + ⋯ + 1/n is known as the harmonic series. In this article, we are going to learn how to find the sum of the series: 1 + 1/2 + 1/3 + ⋯ + 1/n using Python. What is the Harmonic Series? The harmonic series is a mathematical sequence where each term is the reciprocal of a positive integer. It is ...
Read MorePython Program to Toggle Each Character in a String
In this problem, we are given a string, and the task is to toggle the case of each character in the string. This means that all lowercase letters should be converted to uppercase, and all uppercase letters should be converted to lowercase. In this article, we are going to explore different approaches to toggling each character in a string using Python. Let's look at a simple example, where we provide input as "TutorialsPoint". The output would be "tUTORIALSpOINT". In this case, each character is toggled such that uppercase letters become lowercase and lowercase becomes uppercase. Below are different ...
Read MorePython Program to Implement Ternary Search
Searching is one of the most fundamental operations in computer science, and there are multiple algorithms to perform it efficiently. While Binary Search is mainly known to be applied to sorted array searching, Ternary Search is another efficient searching technique that also works on sorted arrays for searching. What is Ternary Search? Ternary Search is a divide-and-conquer algorithm that splits the array into three parts instead of two (as in Binary Search). It repeatedly reduces the search space by two-thirds in each step, making it useful in cases where the dataset is large, and constant-time comparisons are expensive. ...
Read MorePython Program to Find Average of Array Elements
In this article, we will learn how to find the average of array elements using Python, along with examples to demonstrate the implementation. In this problem, we are given an array of integers, which may contain both positive and negative numbers. Our task is to calculate the average of all elements in the array. Using the Brute Force Approach This is a simple and direct approach that involves manually iterating through each element in the array to calculate the sum. Then, we divide the total sum by the count of elements to get the average. This approach is ...
Read MorePython Program to Find Cube of a Number
The cube of a number is a simple mathematical operation where a number is multiplied by itself three times. In Python, there are multiple ways to find the cube of a number. In this article, we are going to discuss various approaches to calculating the cube of a number in Python. What is the Cube of a Number? The formula for finding the cube of a given number N is: Cube = N × N × N or N³ Example 1 Input: 5 Output: ...
Read MorePython Program for Fahrenheit to Celsius conversion
In this problem, we are given a temperature value in Fahrenheit and we have to convert it to Celsius. This conversion is used in various real-world applications such as weather applications, scientific calculations, and data analysis. In this article, we are going to discuss how we can convert Fahrenheit temperature to Celsius temperature in Python. Formula to Convert Fahrenheit to Celsius The formula for converting Fahrenheit to Celsius is: Celsius = (Fahrenheit - 32) / 1.8 Example 1 Input: Fahrenheit = 98.6 Output: Celsius = 37°C ...
Read More