Found 10784 Articles for Python

Compute the inner product of vectors for-D arrays using NumPy in Python

Niharika Aitam
Updated on 07-Aug-2023 17:44:42

106 Views

Inner product is one of the most important operations in the linear algebra mathematical operations, which takes two vectors as input and gives the scalar value as the output. It is also known as the Dot product or the scalar product. The inner product of the two vectors is given as follows. a . b = ||a|| ||b|| cos(Ø) Where, ||a|| and ||b|| are the magnitudes of the vectors a and b respectively Ø is the angle between the vectors a and b a . b is the dot product of a and b Calculating Inner ... Read More

Compute the histogram of a set of data using NumPy in Python

Niharika Aitam
Updated on 07-Aug-2023 17:39:36

111 Views

A Histogram is the graphical representation of the dataset distribution. It represents the data in the form of series of bars, where the range of data values represented by each bar and height of the bar represents the frequency of the data values defined within the range. These are mainly used to represent the distribution of the numerical data like grades in a class, distribution of the population or distribution of the incomes of the employees etc. In histogram, x-axis represents the range of data values, divided into intervals and the y-axis represents the frequency of the range of data ... Read More

Python - Chuncked summation every K value

Niharika Aitam
Updated on 07-Aug-2023 17:24:05

83 Views

Chunked sum also known as partial sum or rolling sum, which is a process of calculating the sum of elements in a sequence such as list, array, or any iterable, in smaller chunks or subsets rather than calculating the sum of the entire sequence at once. Each chunk represents a group of consecutive elements from the sequence, and the sum is calculated for each chunk individually. For example, consider the sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and let's calculate the chunked sum with a chunk size of 3. Chunk 1: [1, 2, 3] → ... Read More

Python - Check possible bijection between a sequence of characters and digits

Niharika Aitam
Updated on 07-Aug-2023 17:23:14

112 Views

In mathematics, a bijection refers to a function that establishes a one-to-one correspondence between two sets. It means that each element in one set has a unique and distinct counterpart in the other set, and vice versa. In other words, a bijection ensures that there are no duplicates or missing elements in the mapping. In the view of programming, specifically Python, checking for a bijection often involves validating whether a one-to-one mapping exists between elements of two sequences or collections. For example, given two lists, A and B, we can check if there is a bijection between their elements by ... Read More

Python - Check Numeric Suffix in String

Niharika Aitam
Updated on 07-Aug-2023 17:22:28

181 Views

Generally, a suffix refers to an affix or a group of letters that is added to the end of a word to modify its meaning or to form a new word. Suffixes are used in linguistics and grammar to create different word forms, such as plurals, verb tenses, comparatives, and more. Suffixes can change the meaning or function of a word in various ways. For example, the suffix "-s" added to the word "cat" forms the plural "cats, " indicating multiple cats. Similarly, the suffix "-ed" added to the verb "walk" creates the past tense "walked, " indicating an action ... Read More

Check if a tuple exists as dictionary key in Python

Niharika Aitam
Updated on 07-Aug-2023 17:21:40

1K+ Views

A Dictionary is one of the data structures available in python which stores the data in the format of key and value pairs. It is mutable i.e., once the data is defined in the dictionary we can make the modifications on the data. It is an unordered collection of elements. The key in the dictionary is unique and the values can be duplicates. The key and value are separated by using the colon (:). On the other hand, a tuple is an ordered collection of elements, enclosed in parentheses (), separated by commas. It is immutable, which means the values ... Read More

Clustering, Connectivity and other Graph properties using Python Networkx

Niharika Aitam
Updated on 07-Aug-2023 17:20:55

640 Views

Python NetworkX is a popular open-source Python library used for the creation, manipulation, and analysis of complex networks or graphs. It provides a wide range of tools, algorithms, and functions to work with graphs, making it a valuable resource for network analysis and research. Python NetworkX allows us to represent and work with different types of graphs, such as directed graphs, undirected graphs, multigraphs (graphs with multiple edges between nodes), and weighted graphs (graphs with edge weights). It also provides a simple and intuitive interface for creating, adding nodes and edges, and performing various operations on graphs. Installation and importing ... Read More

How to Check if a substring is a part of List of Strings using Python?

Niharika Aitam
Updated on 07-Aug-2023 17:19:59

75 Views

Generally, a string is an immutable data structure which is used to store the data in the string format within the single quotes or within the double quotes. It is immutable which means once the string is created the data in the string can’t be changed but can perform various operations on strings to manipulate the data A substring is a contiguous sequence of characters within a larger string. It is a smaller part of a string that can be extracted or searched within the original string. For example, let’s consider the string "Hello, World!" as the original string and ... Read More

How to view the parameters in axes_style in Seaborn?

Niharika Aitam
Updated on 07-Aug-2023 17:19:13

92 Views

Seaborn's 'axes_style()' function allows us to customize the style of plots by modifying various parameters. It returns a dictionary of parameters that control the appearance of the plot elements, such as colors, fonts, gridlines, and more. To view these parameters, we can print the dictionary returned by 'axes_style()'. Importing Required Libraries Before we begin, let's import the necessary libraries. We need to import Seaborn by using the following command. import seaborn as sns Viewing Parameters To view the available parameters in 'axes_style()', we can simply print the dictionary returned by the function. Example When we run the below code, ... Read More

Complexity Cheat Sheet for Python Operations

Niharika Aitam
Updated on 07-Aug-2023 17:06:43

514 Views

Time complexity is a measure of time, which determines the time required for the algorithm to execute. It also checks how the running time is being increased when the size of the inputs is getting increased. The time complexity is represented with the notation capital O, which sets an upper bound in the worst case performance of an algorithm. Whenever we design an algorithm we should keep in mind not only about the correctness but also about the time complexity and performance characteristics. For example, if an algorithm has time complexity O(n) that would take twice of O(n) to execute ... Read More

Advertisements