
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

3K+ Views
To make a custom color, we can create a hexadecimal string. From it, we can make different sets of color representation and can pass into the scatter method to get the desired output.StepsTake an input from the user for the number of colors, i.e., number_of_colors = 20.Use Hexadecimal alphabets to get a color.Create a color from (step 2) by choosing a random character from step 2 data.Plot scatter points for step 1 input data, with step 3 colors.To show the figure, use plt.show() method.Exampleimport matplotlib.pyplot as plt import random number_of_colors = int(input("Please enter number of colors: ")) hexadecimal_alphabets ... Read More

4K+ Views
First, we can initialize an array matrix and pass it into the imshow method that can help to get the image for the given matrix.StepsCreate a 2D Array i.e., img.Using imshow() method, display the data as an image, i.e., on a 2D regular raster.Use plt.show() method to show the figure.Exampleimport matplotlib.pyplot as plt img = [[1, 2, 4, 5, 6, 7], [11, 12, 14, 15, 16, 17], [101, 12, 41, 51, 61, 71], [111, 121, 141, 151, 161, 171]] plt.imshow(img, extent=[0, 5, 0, 5]) plt.show()Output

387 Views
Using plt.subplots(1, 1) method, we can create fig and axis. We can use fig.colorbar to make the color bar at the midpoint of the figure.StepsUsing mgrid() method, `nd_grid` instance which returns an open multi-dimensional "meshgrid".Create Z1, Z2 and Z data.Create fig and ax variables using subplots method, where default nrows and ncols are 1, using subplots() method.Create a colorbar for a ScalarMappable instance, *mappable*, using colorbar() method.Using plt.show(), we can show the figure.Exampleimport numpy as np import matplotlib.pyplot as plt import matplotlib.colors as colors N = 100 X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)] Z1 = np.exp(-(X)**2 - ... Read More

7K+ Views
ROC − Receiver operating characteristics (ROC) curve.Using metrics.plot_roc_curve(clf, X_test, y_test) method, we can draw the ROC curve.StepsGenerate a random n-class classification problem. This initially creates clusters of points normally distributed (std=1) about vertices of an ``n_informative``-dimensional hypercube with sides of length ``2*class_sep`` and assigns an equal number of clusters to each class.It introduces interdependence between these features and adds various types of further noise to the data. Use the make_classification() method.Split arrays or matrices into random trains, using train_test_split() method.Fit the SVM model according to the given training data, using fit() method.Plot Receiver operating characteristic (ROC) curve, using plot_roc_curve() method.To ... Read More

6K+ Views
The datetime module in Python can be used to find the first day of the given year. In general, this datetime module is mostly used for manipulating dates and times. Some of the Common approaches to print the first day of the given year by using Python are as follows. Datetime Module: Widely used library for manipulating dates and times in various ways. Calendar Module: Provides functions related ... Read More

184 Views
We need to write a Python program which will remove a certain substring from a given stringAlgorithmStep 1: Define a string. Step 2: Use the replace function to remove the substring from the given string.Example CodeLive Demooriginal_string = "C++ is a object oriented programming language"modified_string = original_string.replace("object oriented", "")print(modified_string)OutputC++ is a programming languageExplanationThe in-build Python replace() function takes the following parameters:Oldstring: The string which you want to removeNewstring: The new string you want to replace in place of the oldstringCount: Optional. Number of times you want to replace the oldstring with the newstringRead More

467 Views
In this program, we will print today's, yesterday's and tomorrow's dates using the numpy library.AlgorithmStep 1: Import the numpy library. Step 2: find today's date using the datetime64() function. Step 3: find yesterday's date by subtracting the output of timedelta64() function from the output of datetime64() function. Step 4: Find yesterday's date by adding the output of timedelta64() function from the output of datetime64() function.Example Codeimport numpy as np todays_date = np.datetime64('today', 'D') print("Today's Date: ", todays_date) yesterdays_date = np.datetime64('today', 'D') - np.timedelta64(1, 'D') print("Yesterday's Date: ", yesterdays_date) tomorrows_date = np.datetime64('today', 'D') + np.timedelta64(1, 'D') print("Tomorrow's Date: ... Read More

411 Views
Using Pandas, we can create a data frame and create a figure and axis. After that, we can use the scatter method to draw points.StepsCreate lists of students, marks obtained by them, and color codings for each score.Make a data frame using Panda’s DataFrame, with step 1 data.Create fig and ax variables using subplots method, where default nrows and ncols are 1.Set the X-axis label using plt.xlabel() method.Set the Y-axis label using plt.ylabel() method.A scatter plot of *y* vs. *x* with varying marker size and/or color.To show the figure, use plt.show() method.Examplefrom matplotlib import pyplot as plt import pandas as ... Read More

562 Views
We can first activate the figure using plt.ion() method. Then, we can update the plot with different sets of values.StepsCreate fig and ax variables using subplots method, where default nrows and ncols are 1.Draw a line, using plot() method.Set the color of line, i.e., orange.Activate the interaction, using plt.ion() method.To make the plots interactive, change the line coordinates.ExampleIn [1]: %matplotlib auto Using matplotlib backend: GTK3Agg In [2]: import matplotlib.pyplot as plt # Diagram will get popped up. Let’s update the diagram. In [3]: fig, ax = plt.subplots() # Drawing a line In [4]: ax.plot(range(5)) In ... Read More