{"id":5558,"date":"2023-10-27T09:30:52","date_gmt":"2023-10-27T04:00:52","guid":{"rendered":"https:\/\/python-programs.com\/?p=5558"},"modified":"2023-11-10T12:02:18","modified_gmt":"2023-11-10T06:32:18","slug":"python-create-boolean-numpy-array-with-all-true-or-all-false-or-random-boolean-values","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-create-boolean-numpy-array-with-all-true-or-all-false-or-random-boolean-values\/","title":{"rendered":"Python : Create boolean Numpy array with all True or all False or random boolean values"},"content":{"rendered":"

How to create boolean Numpy array with all True or all False or random boolean values in Python ?<\/h2>\n

This article is about creating boolean Numpy array with all True or all False or random boolean values. Here we will discuss various ways of creating boolean Numpy array. So let’s start the topic.<\/p>\n

Approach-1 : Creating 1-D boolean Numpy array with random boolean values<\/h3>\n

Python’s Numpy module provide random.choice( )<\/code> function which will create a boolean Numpy array with some random values.<\/p>\n

Syntax : numpy.random.choice(a, size=None, replace=True, p=None)<\/pre>\n

where,<\/p>\n