Boolean Expressions
Boolean Values & Expressions
bool1 = TrueA Boolean value directly assigned as
True.
bool2 = 3*3 == 9Evaluates if
3 * 3is equal to9→True.
bool3 = FalseA Boolean value directly assigned as
False.
bool4 = 3*3 != 9Evaluates if
3 * 3is not equal to9→False.
Output:
print(bool1, bool2, bool3, bool4)Displays the values:
True True False False
print(type(bool1))Shows the data type of
bool1, which is:<class 'bool'>
✅ Summary:
Boolean values:
TrueorFalse.Used in comparisons like
==(equals) and!=(not equals).Helpful in conditions and decision-making in code.
#!/bin/python3
#Boolean Expressions
bool1 = True
bool2 = 3*3 == 9
bool3 = False
bool4 = 3*3 != 9
print(bool1,bool2,bool3,bool4)
print(type(bool1))
Last updated