-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboolean.py
46 lines (30 loc) · 854 Bytes
/
boolean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#what is Boolean
#A Boolean value is either True or False. In Python, you can create a Boolean value by assigning
# True or False to a variable:
#Example:
x = True
y = False
#You can use Boolean values in comparisons and logical operations:
x = 10
y = 5
# Greater than
z = x > y # z is True
# Less than
z = x < y # z is False
# Equal to
z = x == y # z is False
# Not equal to
z = x != y # z is True
#You can use the and and or operators to perform logical operations:
x = True
y = False
# AND
z = x and y # z is False
# OR
z = x or y # z is True
#You can use the not operator to negate a Boolean value:
x = True
y = not x # y is False
#Boolean values are an important part of Python programming, as they allow you to control the flow of your code and make
# decisions based on certain conditions.
# https://youtube.com/@codewithmuh