Important Notice:

Boolean (bool) Data Type

Boolean (bool) Data Type

3 views 2 min read

Boolean (bool) Data Type (बूलियन डेटा टाइप) :-

Boolean (बूलियन) Python का एक Built-in Data Type है, जिसका उपयोग किसी Condition (शर्त) या Expression (व्यंजक) के परिणाम को दर्शाने के लिए किया जाता है।

Boolean Data Type में केवल दो ही Values होती हैं:

  • True (सत्य)
  • False (असत्य)

जब भी Python में किसी दो Values की तुलना (Comparison) की जाती है, कोई Logical Operation किया जाता है या किसी Condition की जाँच की जाती है, तब परिणाम Boolean Value (True या False) के रूप में प्राप्त होता है।

उदाहरण के लिए यदि पूछा जाए कि 5, 3 से बड़ा है या नहीं, तो इसका उत्तर केवल दो में से एक होगा—

  • यदि कथन सही है → True
  • यदि कथन गलत है → False

इसी कारण Boolean Data Type का उपयोग मुख्य रूप से Decision Making (निर्णय लेने) में किया जाता है।

Boolean शब्द का नाम प्रसिद्ध अंग्रेज़ गणितज्ञ George Boole के नाम पर रखा गया है।

example 1-

a = True
b = False

print(a)
print(b)
print(type(a))
 
Output-
True
False
<class 'bool'>
 

example 2-

marks = 45

print(marks >= 33)
 
Output-
True
 
 English-

Boolean is a Built-in Data Type in Python that is used to represent the result of a condition or an expression.

A Boolean data type can store only two values:

  • True
  • False

Whenever two values are compared in Python, a logical operation is performed, or a condition is evaluated, the result is returned as a Boolean value (True or False).

For example, if you ask whether 5 is greater than 3, the answer can only be one of the following:

  • If the statement is correct → True
  • If the statement is incorrect → False

For this reason, the Boolean data type is mainly used for decision making in Python programs.

The term Boolean is named after the famous English mathematician George Boole, who developed Boolean Algebra, the foundation of modern computer logic.

example-

a = True
b = False

print(a)
print(b)
print(type(a))
 
Output-
True
False
<class 'bool'>

Related Notes