Programming Articles - Page 2351 of 3366

Data analysis and Visualization with Python program

Hafeezul Kareem
Updated on 01-Nov-2019 07:58:30

381 Views

In this tutorial, we are going to learn about data analysis and visualization using modules like pandas and matplotlib in Python. Python is an excellent fit for the data analysis things. Install the modules pandas and matplotlib using the following commands.pip install pandaspip install matplotlibYou will get a success message after the completion of the installation process. We will first learn about the pandas and then will see matplotlib.pandasPandas is an open-source library of Python which provides data analysis tools. We are going to see some useful methods from the pandas for data analysis.Creating DataFramesWe need multiple rows to create ... Read More

type and isinstance in Python program

Hafeezul Kareem
Updated on 01-Nov-2019 07:49:32

215 Views

In this tutorial, we are going to learn about the type and isinstance built-in functions of Python. These functions are used to determine the type of an object in general. Let's see them one by one.type(object)type is used to know the type of an object. For example, if we have an object val with value 5. The type of that object is int. We can get that using the type function. Let's follow the general procedure to achieve the result.Initialize the object.Get the type of the object using type(object) function.Display the type.Below is one example which explains the type(object) function.Example# ... Read More

Automated software testing with Python

Hafeezul Kareem
Updated on 01-Nov-2019 07:51:47

697 Views

In this tutorial, we are going to learn about automating testing in Python. After writing code, we have to test them by giving different types of input and check whether the code is working correctly or not.We can do it manually or automatically. Doing manual testing is very hard. So, we are going to learn about automated testing in Python. Let's start.We have a module called unittest, which is used to test the code automatically. We are going to work with this module in this tutorial. It's straightforward for a beginner to get started with the unittest module for testing. ... Read More

Find frequency of smallest value in an array in C++

Arnab Chakraborty
Updated on 01-Nov-2019 07:23:53

367 Views

Here we will see how to find the frequency of smallest element in an array. Suppose the array elements are [5, 3, 6, 9, 3, 7, 5, 8, 3, 12, 3, 10], here smallest element is 3, and the frequency of this element is 4. So output is 4.To solve this we will find the smallest element of the list, then we count the occurrences of first numbers, and that will be the result.Example#include using namespace std;    int min_element(int arr[], int n){    int min = arr[0];    for(int i = 1; i

Find Excel column number from column title in C++

Arnab Chakraborty
Updated on 01-Nov-2019 07:21:57

273 Views

We know that the excel column numbers are alphabetic. It starts from A, and after Z, it will AA, AB, to ZZ, then again AAA, AAB, to ZZZ and so on. So column 1 is A, column 27 is Z. Here we will see how to get the column letter if number of column is given. So if the column number is 80, then it will be CB.Suppose we have a number n, and its value is 28, then we need to take reminder with 26. If the remainder is 0, then the number is 26, 52 and so on. ... Read More

Find elements which are present in first array and not in second in C++

Arnab Chakraborty
Updated on 01-Nov-2019 07:19:55

183 Views

Suppose we have two arrays A and B. There are few elements. We have to find those elements that are present in set A, but not in set B. If we think that situation, and consider A and B as set, then this is basically set division operation. The set difference between A and B will return those elements.Example#include #include #include #include using namespace std; void setDiffResults(int A[], int B[], int An, int Bn) {    sort(A, A + An);    sort(B, B + Bn);    vector res(An);    vector::iterator it;    vector::iterator it_res = set_difference(A, A + An, B ... Read More

Find elements of array using XOR of consecutive elements in C++

Arnab Chakraborty
Updated on 01-Nov-2019 07:16:08

336 Views

Consider we have to find a list of n elements. But we have the XOR value of two consecutive elements of the actual array. Also the first element of the actual is given. So if the array elements are a, b, c, d, e, f, then the given array will be a^b, b^c, c^d, d^e and e^f.As the first number is given, named a, that can help us to find all numbers. If we want to find the second element of the actual array, then we have to perform b = a ^ arr[i], for second element c = b ... Read More

Find duplicates under given constraints in C++

Arnab Chakraborty
Updated on 01-Nov-2019 07:13:57

196 Views

Suppose we have a list with 6 different numbers. Only one number is repeated five times. So there are total 10 elements in the array. Find duplicate numbers using only two comparisons. If the list is like [1, 2, 3, 4, 4, 4, 4, 4, 5, 6], so output is 4.As there are only 10 numbers, then for any type of duplicate numbers, the range of numbers will be placed from index 3 to 5. By checking these indices, we can find the result.Example#include using namespace std; int getDuplicate(int array[]) {    if (array[3] == array[4])       return array[3];    else if (array[4] == array[5])       return array[4];    else       return array[5]; } int main() {    int a[] = {1, 2, 3, 4, 4, 4, 4, 4, 5, 6};    cout

Program to print the nodes at odd levels of a tree using C++

Ayush Gupta
Updated on 01-Nov-2019 07:13:41

162 Views

In this tutorial, we will be discussing a program to print the nodes present at the odd levels of a given binary tree.In this program, the level for the root node is considered as 1 and simultaneously the alternative level is the next odd level.For example, let us say we are given with the following binary treeThen the nodes at the odd levels of this binary tree will be 1, 4, 5, 6.Example#include using namespace std; struct Node {    int data;    Node* left, *right; }; //printing the nodes at odd levels void print_onodes(Node *root, bool is_odd = ... Read More

Find duplicates in O(n) time and O(1) extra space - Set 1 in C++

Arnab Chakraborty
Updated on 01-Nov-2019 07:12:01

337 Views

Suppose we have a list of numbers from 0 to n-1. A number can be repeated as many as possible number of times. We have to find the repeating numbers without taking any extra space. If the value of n = 7, and list is like [5, 2, 3, 5, 1, 6, 2, 3, 4, 5]. The answer will be 5, 2, 3.To solve this, we have to follow these steps −for each element e in the list, do the following steps −sign := A[absolute value of e]if the sign is positive, then make it negativeOtherwise it is a repetition.Example#include ... Read More

Advertisements