MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Can boolean values be stored in an python array?
A
Yes
B
no
C
As long as they only evaluate to true
D
As long as they only evaluate to false
Explanation: 

Detailed explanation-1: -If you want to define a boolean in Python, you can simply assign a True or False value or even an expression that ultimately evaluates to one of these values. You can check the type of the variable by using the built-in type function in Python.

Detailed explanation-2: -Use the Boolean Data Type (Visual Basic) to contain two-state values such as true/false, yes/no, or on/off. The default value of Boolean is False . Boolean values are not stored as numbers, and the stored values are not intended to be equivalent to numbers.

Detailed explanation-3: -A boolean array is a numpy array with boolean (True/False) values. Such array can be obtained by applying a logical operator to another numpy array: import numpy as np a = np. reshape(np. arange(16), (4, 4)) # create a 4x4 array of integers print(a)

Detailed explanation-4: -Boolean data types can be used to store the values true and false in a database.

There is 1 question to complete.