Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 2120 of 2650
156 Views
Here we will see how to get the length of each string element in the Numpy Array. Numpy is a library for Numeric Python, and it has very powerful array class. Using this we can store data in an array like structure. To get the length we can follow two different approach, these are like below −Exampleimport numpy as np str_arr = np.array(['Hello', 'Computer', 'Mobile', 'Language', 'Programming', 'Python']) print('The array is like: ', str_arr) len_check = np.vectorize(len) len_arr = len_check(str_arr) print('Respective lengts: ', len_arr)OutputThe array is like: ['Hello' 'Computer' 'Mobile' 'Language' 'Programming' 'Python'] Respective lengts: [ 5 8 6 8 ... Read More
4K+ Views
The Dictionary.ContainsValue() method in C# is used to check whether the Dictionary contains a specific value or not.Syntaxpublic bool ContainsValue (TValue val);Above, Val is the value to be searched.Let us now see an example to implement the Dictionary.ContainsValue() method −Exampleusing System; using System.Collections.Generic; public class Demo { public static void Main(){ Dictionary dict = new Dictionary(); dict.Add("One", "John"); dict.Add("Two", "Tom"); dict.Add("Three", "Jacob"); dict.Add("Four", "Kevin"); dict.Add("Five", "Nathan"); Console.WriteLine("Count of elements = "+dict.Count); Console.WriteLine("Key/value ... Read More
261 Views
Suppose we have an array of n elements. We have to find the first, second and the third minimum elements in the array. First minimum is the minimum of the array, second min is minimum but larger than the first one, and similarly the third min is minimum but greater than second min.Scan through each element, then check the element, and relate the condition for first, second and third min elements conditions to solve this problem.Example#include using namespace std; int getThreeMins(int arr[], int n) { int first = INT_MAX, sec = INT_MAX, third = INT_MAX; for ... Read More
115 Views
Consider we have the initial values of two positive integers X and Y. Find the final value of X and Y, such that there will be some alteration as mentioned below −step1 − If X = 0 and Y = 0 then terminate the process, otherwise go to step2step2 − If X >= 2Y, then set X = X – 2Y, and go to step1, otherwise go to step3step3 − If Y >= 2X, then set Y = Y – 2X, and go to step1, otherwise end the process.The number X and Y will be in range [0 and 1018] ... Read More
251 Views
Consider we have an array A, which is sorted. It has all elements appears twice, but one element is present for only one time. We have to find that element. If the array is [1, 1, 3, 3, 4, 4, 5, 6, 6, 7, 7, 9, 9], so the single element is 5.We will use the binary search approach to solve this. All elements before the single element has their first occurrence at index 0, 2, 4, … and first occurrence at index 1, 3, 5, … but after the single element, all occurrences of the first number will be ... Read More
355 Views
An anagram is a rearrangement of the characters of a word or a phrase to generate a new word, using all the original characters exactly once. For example, thing and night are anagrams of each other. An anagram substring search includes two strings (text, pattern); we need to search the given text for any substring that contains the same characters as the pattern, in any order. Scenario Following is an example scenario: Input: str1="cbaebabacd", str2="abc" Output: [0, 6] Explanation: In this case, The substring "cba" at index 0 is an anagram of "abc". The substring "bac" at index 6 is an ... Read More
35K+ Views
In this tutorial, we are going to learn how to add a new column to the existing DataFrame in pandas. We can have different methods to add a new column. Let's all of them.Using ListWe can add a new column using the list. Follow the steps to add a new column.Algorithm1. Create DataFrame using a dictionary. 2. Create a list containing new column data. Make sure that the length of the list matches the length of the data which is already present in the data frame. 3. Add the list to the DataFrame like dictionary element.Let's see one example.Example# importing ... Read More
304 Views
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. For example, thing and night are anagrams of each other. In this article, we are going to learn how to check an anagram in a Python program using collections.Counter() method. This method counts the number of occurrences of each element in a collection (like characters in a string), helping us to compare two words for identical character counts. For example, Scenario Input: str1= "listen", str2= "silent" Output: True Two strings are said ... Read More
218 Views
The Telecom Regulatory Authority of India (TRAI) publishes the data regarding mobile internet speeds for various telecom operations across India. It is useful for users and telecom companies to evaluate and compare the performance of different service providers. In this article, we are going to use pandas in Python to analyze the TRAI mobile data speed reports. Let's assume we have downloaded the CSV file named demo.csv with the following structure to use in the examples. demo.csv file ... Read More