
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Determine whether the given object represents a scalar data-type in Python
To determine whether the given object represents a scalar data-type, use the numpy.issctype() method. The method returns Boolean result of check whether rep is a scalar dtype. The first parameter is the rep. If rep is an instance of a scalar dtype, True is returned.If not, False is returned.
Steps
At first, import the required library −
import numpy as np
Using the issctype() method in Numpy −
print("Result...",np.issctype(np.int32)) print("Result...",np.issctype(np.int64)) print("Result...",np.issctype(np.dtype('str'))) print("Result...",np.issctype(100)) print("Result...",np.issctype(25.9)) print("Result...",np.issctype(np.float32(22.3)))
Example
import numpy as np # To determine whether the given object represents a scalar datatype, use the numpy.issctype() method # The method returns Boolean result of check whether rep is a scalar dtype. # The first parameter is the rep. If rep is an instance of a scalar dtype, True is returned.If not, False is returned. print("Using the issctype() method in Numpy\n") print("Result...",np.issctype(np.int32)) print("Result...",np.issctype(np.int64)) print("Result...",np.issctype(np.dtype('str'))) print("Result...",np.issctype(100)) print("Result...",np.issctype(25.9)) print("Result...",np.issctype(np.float32(22.3)))
Output
Using the issctype() method in Numpy Result... True Result... True Result... True Result... False Result... False Result... False
- Related Articles
- Find the minimal data type of a scalar value in Python
- Python program to determine whether the given number is a Harshad Number
- Return the scalar dtype or NumPy equivalent of Python type of an object
- How to check whether the given date represents weekend in Java
- Return a description for the given data type code in Python
- Return the data type with the smallest size and scalar kind to which both the given types be safely cast in Python
- Python Program to Determine Whether a Given Number is Even or Odd Recursively
- Change data type of given numpy array in Python
- Determine the type of an image in Python?
- Return a scalar type which is common to the input arrays in Python
- Return True if cast between scalar and data type can occur according to the casting rule in Python
- Return True if cast between array scalar and data type can occur according to the casting rule in Python
- Python Type Object
- How to determine database type (name) for a given JDBC connection?
- What is a composite data type i.e. object in JavaScript?

Advertisements