Hurry! Try our new Interactive Courses for FREE. 🥳   🚀

NumPy islower() function

In this tutorial, we will cover islower() function in the char module of the Numpy Library in Python.

The islower() function of the Numpy library returns true for each element if all cased characters in the input string are in lowercase and there is at least one cased character. Otherwise, this function will return false.

  • This function calls str.islower in an element-wise manner.

  • This function is locale-dependent for an 8-bit string.

Syntax of islower():

The syntax required to use this function is as follows:

numpy.char.islower(a)

The above syntax indicates that islower() is a function of the char module and it takes a single parameter.

In the above syntax, the argument a represents the input array of the string on which this function will be applied.

Returned Values:

This function will return an output array of boolean values.

Example 1: With a String

In this first example, we will apply the islower() function on a single string value:

import numpy as np

string1 = "this is an apple"
x = np.char.islower(string1)
print("After applying islower() function:")
print(x)


After applying islower() function:
True

Example 2: With an Array of Strings

The code snippet is as follows where we will use islower() function:

import numpy as np

inp_ar = np.array(['studytonight', 'Online', 'portal']) 

print ("The input array : \n", inp_ar) 

output = np.char.islower(inp_ar) 
print ("The output array :\n", output) 


The input array :
['studytonight' 'Online' 'portal']
The output array :
[ True False True]

Summary

This tutorial was all about the islower() function of the Numpy Library which is used to find out if a string is in lower case or not.