Found 27104 Articles for Server Side Programming

Dumping queue into list or array in Python

Prabhdeep Singh
Updated on 24-Aug-2023 15:54:25

175 Views

A queue is a linear data structure that works on the FIFO property where each element is added to the queue from the rear and the elements are extracted from the front and use the principle of first in first out. In the list, we can access every element while in the queue we can only access the first element. In this tutorial, we are going to see two methods of how to convert a queue into the list. Creating a Queue in Python Queue in a linear data structure which works on the first in first out property and ... Read More

Permutations and Combinations (Concept, Examples, C++ Program)

Eva Sharma
Updated on 24-Aug-2023 18:27:49

376 Views

Permutations and Combinations refer to the arrangements of objects in mathematics. Permutation − In permutation, the order matters. Hence, the arrangement of the objects in a particular order is called a permutation. Permutations are of two types − Permutation with repetition Suppose we have to make a three-digit code. Some possible numbers are 123, 897, 557, 333, 000, and 001. So how many numbers can we make like this? Let us look at it this way− In the once place, we have ten options − 0-9 Similarly, at the tenth and the hundredth place also, we have ten options. 0-9. ... Read More

HCF of an array of fractions (or rational numbers)

Eva Sharma
Updated on 24-Aug-2023 18:26:00

208 Views

HCF or the Highest common factor of two or more numbers refers to the highest number which divides them. A rational number is the quotient p/q of two numbers such that q is not equal to 0. Problem Statement Given an array with fractional numbers, find the HCF of the numbers. Example 1 Input [{4, 5}, {10, 12}, {24, 16}, {22, 13}] Output {2, 3120} Explanation The fractional numbers given are: 4/5, 10/12, 24/16 and 22/13 2/3120 is the largest number that divides all of them. Example 2 Input [{18, 20}, {15, 12}, {27, 12}, {20, 6}] ... Read More

Stella Octangula Number

Eva Sharma
Updated on 24-Aug-2023 18:19:51

79 Views

In mathematics, a Stella Octangula number is a figurate number based on the Stella Octangula, of the form n(2n2 − 1). Stella Octangula numbers which are perfect squares are 1 and 9653449. Problem Statement Given a number n, check whether it is the Stella Octangula number or not. The sequence of Stella Octangula numbers is 0, 1, 14, 51, 124, 245, 426, 679, 1016, 1449, 1990 Example1 Input x = 14 Output Yes Explanation $$\mathrm{For\: n = 2, expression \:n\lgroup 2n^2 – 1\rgroup is\: 14}$$ Example2 Input n = 22 Output No Explanation $$\mathrm{There \:is\: no\: ... Read More

Nicomachus’ Theorem

Eva Sharma
Updated on 24-Aug-2023 18:17:20

166 Views

According to Nicomachus’ Theorem, the sum of the cubes of the first n integers is equal to the square of the nth triangular number. Or, we can also say − The sum of cubes of first n natural numbers is equal to square of sum of first natural numbers. Putting it algebraically, $$\mathrm{\displaystyle\sum\limits_{i=0}^n i^3=\lgroup \frac{n^2+n}{2}\rgroup^2}$$ Theorem $$1^3 = 1$$ $$2^3 = 3 + 5$$ $$3^3 = 7 + 9 + 11$$ $$4^3 = 13 + 15 + 17 + 19\vdots$$ Generalizing $$n^3 =\lgroup n^2−n+1\rgroup+\lgroup n^2−n+3\rgroup+⋯+\lgroup n^2+n−1\rgroup$$ Proof By Induction For all n Ε Natural ... Read More

Equal sum array partition excluding a given element

Eva Sharma
Updated on 24-Aug-2023 18:00:27

83 Views

Problem Statement For an index and an arr[]. Check if the array[] can be partitioned into two disjoint sets, excluding arr[index] such that the sum of both sets has equal value. Example 1 Input arr[] = {4, 3, 1, 2}, Index = 1 Output No Explanation We have to exclude arr[1] = 3 All possible sets are − Set 1: (4), Set 2: (2, 1), sum = 4≠3 Set 1: (4, 1), Set 2: (2), sum = 5≠2 Set 1: (4, 2), Set 2: (1), sum = 6≠1 No combination satisfies the conditions. Example 2Input arr[] ... Read More

Squared Triangular Number (Sum of Cubes)

Eva Sharma
Updated on 24-Aug-2023 17:58:22

58 Views

A square triangular number, also referred to as a triangular square number, is a number that is both a triangular number and a perfect square. Square triangular numbers have an unlimited number of possible values; the first few are − 0, 1, 36, 1225, 41616... A triangular number or triangle number counts objects arranged in an equilateral triangle. The nth triangular number is the number of dots in the triangular arrangement with n dots on each side and is equal to the sum of the n natural numbers from 1 to n. The sequence of triangular numbers, ... Read More

Handling Missing Data in Python Causes and Solutions

Satish Kumar
Updated on 23-Aug-2023 17:17:05

145 Views

Introduction Missing data is a common issue in data analysis and can occur due to various reasons. In Python, missing values are often represented as NaN (Not a Number) or None. Missing data can cause inaccurate analysis results and lead to biased conclusions if not handled properly. Therefore, handling missing data is an essential part of any successful data analysis project. Causes of Missing Data in Python Missing data is a common challenge that data analysts and scientists often encounter in their work. In Python, there are various reasons why data may be missing. Understanding these causes can help analysts ... Read More

Allowing resizing window in PyGame

Priya Mishra
Updated on 24-Aug-2023 17:53:40

1K+ Views

Introduction Pygame is the module used for game development in Python; it is considered to be one of the most effective modules for this purpose. The development of video games can not only be profitable in today's market but also serve as a medium for educational and promotional purposes. Creating games requires knowledge of mathematics, logic, physics, artificial intelligence, and a lot of other subjects, yet it can be really enjoyable. We will discuss in detail what is Pygame, how to implement a normal PyGame window and how to allow users to resize the window with a working example. ... Read More

Append data to an empty Pandas DataFrame

Priya Mishra
Updated on 24-Aug-2023 17:48:28

169 Views

Introduction A data structure known as a data frame is a two-dimensional labelled array with columns that might be of various data kinds. You can compare it to a spreadsheet, a SQL table, or even a dict of Series objects to better understand it. It is the panda item that is used the vast majority of the time. In addition to the data itself, you have the option of also passing parameters for the index (row labels) and columns (column labels). If you supply an index and/or columns, you are assuring that those elements will be present in the DataFrame ... Read More

Advertisements