Programming Articles - Page 741 of 3363

Java program to find the area of a parallelogram

AmitDiwan
Updated on 21-Oct-2024 11:06:11

625 Views

In this article, we will understand how to find the area of a parallelogram using Java. A parallelogram has two pairs of parallel equal opposite sides. It has a base and a height which is the perpendicular distance between the base and its opposite parallel side. The area of a parallelogram is calculated using the formula − base * height i.e. b x h Problem Statement Write a program in Java to find the area of a parallelogram. Below is a demonstration of the same − Input Base : 6 Height : 8 Output Area parallelogram is ... Read More

Check which element in a masked array is greater than a given value

AmitDiwan
Updated on 22-Feb-2022 07:38:58

189 Views

To check which element in a masked array is greater than the given value, use the ma.MaskedArray.__gt__() method. True is returned for every array element greater than the given value val. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of ... Read More

Java Program to Perform nCr (rcombinations)

Alshifa Hasnain
Updated on 27-Dec-2024 19:16:15

989 Views

In this article, we'll learn to perform nCr (Combinations) in Java. In mathematics, nCr (combinations) is a crucial concept that helps determine how many ways you can choose r items from a set of n items, without considering the selection order. It is widely used in fields like probability, statistics, and combinatorics.  What is nCr? The formula for calculating combinations (nCr) is − nCr = n! / (r! × (n - r)!) Where, n! = The factorial of n (product of all integers from 1 to n). r! = The factorial ... Read More

Check which element in a masked array is less than or equal to a given value in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:34:09

349 Views

To check which element in a masked array is less than or equal to a given value, use the ma.MaskedArray.__le__() method. Returns with boolean type i.e. True and False. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and ... Read More

Check which element in a masked array is less than the given value in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:28:15

134 Views

To check which element in a masked array is less than the given value, use the ma.MaskedArray.__lt__() method. Returns with boolean type i.e. True and False. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and ... Read More

Return the variance of the masked array elements along given axis in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:22:51

184 Views

To return the variance of the masked array elements, use the ma.MaskedArray.var() in Numpy. The axis is set using the axis parameter. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.The “axis” parameter is the axis or axes along which the variance is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as ... Read More

Return the variance of the masked array elements in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:19:53

240 Views

To return the variance of the masked array elements, use the ma.MaskedArray.var() in Python Numpy. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.The “axis” parameter is the axis or axes along which the variance is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before. The dtype is the type to ... Read More

Shift the bits of array elements of a Two-Dimensional array to the right in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:16:21

491 Views

To shift the bits of array elements of a 2d array to the right, use the numpy.right_shift() method in Python Numpy. Bits are shifted to the right x2. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing x1 by 2**x2.The x1 is the Input values. The x2 is the number of bits to remove at the right of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape.The function right_shift() returns x1 with bits shifted x2 times to the right. This is a scalar if both x1 and x2 are ... Read More

Shift the bits of an integer to the right and set the count of shifts as an array with signed integer type in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:12:20

161 Views

To shift the bits of an integer to the right, use the numpy.right_shift() method in Python Numpy. We have set the count of shifts as a new array. Bits are shifted to the right x2. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing x1 by 2**x2.The x1 is the Input values. The x2 is the number of bits to remove at the right of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape.The function right_shift() returns x1 with bits shifted x2 times to the right. This is a ... Read More

Return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa in Numpy

AmitDiwan
Updated on 22-Feb-2022 07:08:53

341 Views

To return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa, use the numpy.char.swapcase() method in Python Numpy. For 8-bit strings, this method is locale-dependent.The function swapcase() returns an output array of str or unicode, depending on input type. The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_ or numpy.bytes_.StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['Katie', 'JOHN', 'Kate', 'AmY', 'brADley']) Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array ... Read More

Advertisements