Found 33676 Articles for Programming

Get the itemsize of the masked array in Numpy

AmitDiwan
Updated on 21-Feb-2022 11:03:07

193 Views

To get the itemsize of the Masked Array, use the ma.MaskedArray.itemsize attribute in Numpy. 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.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate a numpy array using the numpy.array() method −arr = np.array([[35, 85], [67, 33]]) print("Array...", arr) print("Array type...", arr.dtype) print("Array itemsize...", arr.itemsize)Get the dimensions of ... Read More

Java Program to Print the ASCII values

Shriansh Kumar
Updated on 13-Sep-2024 16:14:00

1K+ Views

For a given character, say "ch", write a Java program to print its ASCII value. We can find the ASCII value of any character by assigning it to an integer value and printing that integer value. The term ASCII stands for American Standard Code for Information Interchange. There are 128 standard ASCII codes, each of which can be represented by a 7-digit binary number: 0000000 through 1111111. Extended ASCII adds an additional 128 characters that vary between computers, programs and fonts. Example Scenario: Input: character = s; Output: ascii_value = 115 Example 1 In this example, we are printing ... Read More

Get the information about the memory layout of the masked array in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:59:02

186 Views

To get the information about the memory layout of the masked array, use the ma.MaskedArray.flags in Numpy. Masked arrays are arrays that may have missing or invalid entries. The numpy.ma module provides a nearly work-alike replacement for numpy that supports data arrays with masks.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.StepsAt first, import the required library −import numpy as ... Read More

Java Program to Convert Decimal to Octal

Shriansh Kumar
Updated on 06-Jun-2025 13:04:10

771 Views

The octal number system has a base value of 8 as it contains digits from 0 to 7, i.e., 8. On the other hand, the decimal number system has 10 digits from 0 to 9. Hence, its base value is 10. In this article, we will learn to convert decimals to the octal number system in Java. Problem Statement The goal is to write a program to convert a given decimal number (base 10) into its equivalent octal number (base 8). Example Scenario: Input: int decimalNumber = 8 Output: The octal value is = 10 Converting Decimal to Octal in ... Read More

Compute the bit-wise XOR of two boolean arrays element-wise in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:55:58

466 Views

To compute the bit-wise XOR of two boolean arrays element-wise, use the numpy.bitwise_xor() method in Python Numpy.Computes the bit-wise XOR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ^.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape.StepsAt first, import the required library −import numpy as npCreating two numpy boolean arrays using the array() method −arr1 = np.array([[False, False, False],    [True, False, True]]) arr2 = np.array([[False, True, False],    [False, False, False]])Display ... Read More

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

AmitDiwan
Updated on 21-Feb-2022 10:51:09

134 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. The axis is set to 0, for column axis.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 ... Read More

Java Program to Find the Perimeter of a Rectangle

Shriansh Kumar
Updated on 01-Aug-2024 11:03:16

1K+ Views

For a given rectangle of length l and width w, write a Java program to find its perimeter. The Perimeter of a rectangle is calculated by adding the lengths of all the sides of the rectangle. Below is a demonstration of a rectangle, a quadrilateral with four right angles (90°). The perimeter of a rectangle is the total length of the two lengths and two widths of the rectangle − Example Scenario: Input: length = 5, 8, 5, 8; Output: Perimeter = 26 On adding all the sides of rectangle, you will get perimeter. 5+8+5+8 = 26 Steps ... Read More

Compute the bit-wise OR of a 1D and a 2D array element-wise in Numpy

AmitDiwan
Updated on 21-Feb-2022 10:40:02

159 Views

To compute the bit-wise OR of a 1D and a 2D array element-wise, use the numpy.bitwise_or() method in Python Numpy. Computes the bit-wise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator |.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape.The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will ... Read More

Java program to calculate the compound interest

Manisha Chand
Updated on 05-Jun-2025 10:48:07

16K+ Views

In this article, we will understand how to calculate compound interest in Java. Compound interest is calculated using the following formula. Amount = P(1 + R/100)t Compound Interest = Amount - Principle where, P is the principal amount T is the time R is the rate Compound interest is the interest calculated on the initial principal and also on the accumulated interest of previous periods. In other words, Compound Interest = Interest on Principal + Interest on Interest. We'll learn how to get user input for the principal amount, interest rate, and time period, and then calculate the compound interest based ... Read More

Return the variance of the masked array elements along row axis

AmitDiwan
Updated on 21-Feb-2022 10:36:54

119 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. The axis is set to 1, for row axisReturns 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 ... Read More

Advertisements