
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
Found 26504 Articles for Server Side Programming

2K+ Views
To plot multiple Seaborn jointplot, we can use the jointplot() method.StepsAdd a subplot to the current figure.Create a dictionary, with some keys.Create a dataframe using Pandas.Make a jointplot using the jointplot() method.To plot the curves, use the plot() method.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.subplot() d = { 'y=1/x': [1 / i for i in range(1, 10)], 'y=x': [i for i in range(1, 10)], 'y=x^2': [i * i for i in range(1, 10)], 'y=x^3': [i ... Read More

5K+ Views
To make the marker face color transparent without making the line transparent in matplotlib, we can take the following steps −Create x_data and y_data(sin(x_data)), using numpy.Plot curve using x_data and y_data, with marker style and marker size. By changing the alpha, we can make it transparent to opaque.To get the essence of transparency (keeping alhpa value lesser), we can make grid lines, to see through.To display the figure, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x_data = np.linspace(1, 10, 100) y_data = np.sin(x_data) plt.plot(x_data, y_data, c='green', marker='o', alpha=.3, ms=10, ... Read More

1K+ Views
To extract a subset of a colormap as a new colormap, we can take the following steps −Create a random array with 10×10 shape.Add a subplot to the current figure, where nrows=1, ncols=2 and index=1.Initialize using get_cmap so that scatter knows.Using imshow() method with colormap, display the data as an image, i.e., on a 2D regular raster, with data and colormap (Steps 1 and 3).Add a subplot to the current figure, where nrows=1, ncols=2 and index=2.Extract a subset of the colormap from the existing colormap (From step 3).Using imshow() method with colormap, display the data as an image, i.e., on a 2D regular raster, ... Read More

2K+ Views
To define a discrete colormap for imshow in matplotlib, we can take following the steps −Create data using numpy.Initialize the data using get_cmap, so that scatter knows.Using imshow() method with colormap, display the data as an image, i.e., on a 2D regular raster.Create the colorbar using the colorbar() method.To display the figure, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt import matplotlib plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(10, 10) cmap = matplotlib.cm.get_cmap('Paired_r', 10) plt.imshow(data, cmap=cmap) plt.colorbar() plt.show()OutputRead More

708 Views
To enforce axis range in matplotlib, we can take the following steps −Set x and y limits using xlim and ylim methods, respectively.Create x and y points for the curve using numpy.Plot x and y using the plot() method.To show the figure, use the show() method.Exampleimport matplotlib.pyplot as plt import datetime import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.array([datetime.datetime(2021, 1, 1, i, 0) for i in range(24)]) y = np.random.randint(100, size=x.shape) plt.plot(x, y) plt.show()Output

110 Views
In this tutorial, we are going to write a program that finds the k-th node in the diagonal traversal of a binary tree.Let's see the steps to solve the problem.Initialise the binary tree with some sample data.Initialise the number k.Traverse the binary tree diagonally using the data structure queue.Decrement the value of k on each node.Return the node when k becomes 0.Return -1 if there is no such node.ExampleLet's see the code. Live Demo#include using namespace std; struct Node { int data; Node *left, *right; }; Node* getNewNode(int data) { Node* node = (Node*)malloc(sizeof(Node)); node->data = ... Read More

650 Views
In this tutorial, we are going to write a program that finds the length of union of segments of a line.We are given starting and ending points of the line segment and we need to find the length of union of segments of the line.The algorithm that we are going to use is called klee's algorithm.Let's see the steps to solve the problem.Initialise the array with coordinates of all the segments.Initialise a vector called points with double the size of segments array.Iterate over the segments array.Fill the values of points array at index i * 2 with the first point ... Read More

425 Views
In this tutorial, we are going to write a program that checks whether the given number is Keith Number or not.The number n is called Keith number if it appears in the sequence generated using its digits. The sequence has first n terms as digits of the number n and other terms are recursively evaluated as sum of previous n terms.Let's see the steps to solve the problem.Initialise the number n.Initialise an empty vector elements to store the sequence.Count the digits and add every digit to the vecor.Reverse the digits vector.Initialise a variable with 0 called next element.Write a loop ... Read More

3K+ Views
In this tutorial, we are going to write a program that finds whether the given number is kaprekar number or not.Take a number. Find the square of that number. Divide the number into two parts. If the sum of the two parts is equal to the original number, then the number is called kaprekar number.Let's see the steps to solve the problem.Initialise the n.Find the square of the n.Find the number of digits in the square of the n and store it in a variable.Divide the square of n with 10, 100, 1000, etc.., until the digits count.Check whether sum ... Read More

857 Views
In this tutorial, we are going to write a program that finds the k-th smallest number in the unsorted array.Let's see the steps to solve the problem.Initialise the array and k.Initialise a empty ordered set.Iterate over the array and insert each element to the array.Iterate over the set from 0 to k - 1.Return the value.ExampleLet's see the code. Live Demo#include using namespace std; int findKthSmallestNumber(int arr[], int n, int k) { set set; for (int i = 0; i < n; i++) { set.insert(arr[i]); } auto it = set.begin(); for (int ... Read More