In this article we will discuss how to list all the functions in a Python module. A Python module contains multiple different functions that allow for extensive code reusability making complex code simple. It also enhances portability of python program by changing platform dependent code into platform independent APIs Python standard library consists of modules written in C that provide access to system functionality and modules written in python that provide general solutions for everyday problems making the life of programmers easy as it prevents writing of long code for simple problems Using dir() to get functions in a module ... Read More
This article teaches you how to write a python program to find all duplicate characters in a string. Characters that repeat themselves within a string are referred to as duplicate characters. When we refer to printing duplicate characters in a string, we mean that we shall print every character, including spaces, that appears more than once in the string in question. Input-Output Scenarios Following is the input-output scenario to find all the duplicate characters in a string − Input: TutorialsPoint Output: t, o, i As we can see, the duplicate characters in the given string "TutorialsPoint" are "t" with ... Read More
We use the function cv2.normalize() to normalize an image in OpenCV. This function accepts the parameters- src, dst, alpha, beta, norm_type, dtype and mask. src and dst are input image and output of the same size as input, alpha is lower norm value for range normalization, beta is upper norm value for range normalization, norm_type is normalization type, dtype is data type of output and mask is optional operation mask. Steps To normalize an image, we could follow the steps given below − Import the required library. In all the following examples, the required Python library is OpenCV. ... Read More
In this article, we will show you how to generate non-repeating random numbers in Python. Below are the methods to accomplish this task: Using randint() & append() functions Using random.sample() method of given list Using random.sample() method of a range of numbers Using random.choices() method Using randint() & append() functions Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Use the import keyword, to import the random module. Create an empty list which is the resultant random numbers list. Use the for loop, to traverse the loop 15 times. Use ... Read More
In this article, we are going to learn how to find the frequency of elements in a Python list. We can solve the problem in different ways. Let's see two of them.Follow the below steps to write the code.Initialize the list with elements and an empty dictionary.Iterate over the list of elements.Check whether the element is present in the dictionary or not.If the element is already present in the dictionary, then increase its count.If the element is not present in the dictionary, then initialize its count with 1.Print the dictionary.ExampleLet's see the code. Live Demo# initializing the list random_list = ['A', ... Read More
In this post, we will understand the difference between the 'for' and the 'while' loop. For Loop A for loop is a control flow statement that executes code for a predefined number of iterations. The keyword used in this control flow statement is "for". When the number of iterations is already known, the for loop is used. The for loop is divided into two parts − Header − This part specifies the iteration of the loop. In the header part, the loop variable is also declared, which tells the body which iteration is being executed. Body − The body part ... Read More
Plotly is an open-source plotting library in Python that can generate several different types interactive web-based visualizations that can be displayed in Jupyter notebooks, saved to standalone HTML files, or served as a part of web applications using Dash. Plotly can also be used in static document publishing and desktop editors such as PyCharm and Spyder. In this tutorial, we will show how you can use Plotly to plot multiple lines on the same Y-axis on a chart. Here we will use plotly.express to generate figures. It contains a lot of methods to customize chart and render a chart into ... Read More
To remove items (elements) from a list in Python, use the list functions clear(), pop(), and remove(). You can also delete items with the del statement by specifying a position or range with an index or slice. In this article, we will show you how to remove an object/element from a list using Python. The following are the 4 different methods to accomplish this task − Using remove() method Using del keyword Using pop() method Using clear() method Assume we have taken a list containing some elements. We will return a resultant list after removing the given item ... Read More
To plot CSV data using Matplotlib and Pandas in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a list of headers of the .CSV file.Read the CSV file with headers.Set the index and plot the dataframe.To display the figure, use show() method.Exampleimport pandas as pd import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True headers = ['Name', 'Age', 'Marks'] df = pd.read_csv('student.csv', names=headers) df.set_index('Name').plot() plt.show()Output
OpenCV is a Python library that is used to solve computer vision problems. Computer vision include understanding and analyzing digital images by the computer and process the images or provide relevant data after analyzing the image.OpenCV is an open-source library used in machine learning and image processing. It performs tasks such as recognizing handwritten digits, human faces, and objects.To use OpenCV, we need to install it.Step 1 − Make sure Python and pip is preinstalled on your systemType the following commands in command prompt to check is python and pip is installed on your system.To check Pythonpython --versionIf Python is ... Read More