1
2a = True # dont forget capital T and F, it is case sensitive
3b = False
4
5if b == True:
6 print("b is true")
7
8if b:
9 print("b is true") # this is the shorthand of the above IF statement
10
11if b == False:
12 print("b is false") # again dont forget True and False are case sensitive
13
1>>> # The not operator is the opposite of it
2>>> not True
3False
4>>> not False
5True
6>>> # The and operator is True only if both are are true
7>>> True and True
8True
9>>> False and True
10False
11>>> False and False
12False
13>>> # The or operator is True if either of them are true
14>>> True or True
15True
16>>> False or True
17True
18>>> False or False
19False
1>>> type(True)
2<class 'bool'>
3>>> type(true)
4Traceback (most recent call last):
5 File "<interactive input>", line 1, in <module>
6NameError: name 'true' is not defined
7
1#The Python Boolean type is one of Python's built-in data types. It's used to represent the truth value of an expression.
2#in this code if you're age is under 13 than a massage will tell you that you are not able to sign up
3Name = input("Povide your name : ")
4Email = input("Provide your email : ")
5age = input("Provide your age : ")
6if age < "13":
7 print("you are not able to sign up")
8else:
9 if age > "13":
10 print("you are able to sign up")
1#Example I found:
2
3my_boolean = 1
4print(bool(my_boolean))
5
6my_boolean = 0
7print(bool(my_boolean))
8
9my_boolean = 10
10print(bool(my_boolean))
11
12print("Coding" == "fun")