-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbooleans.py
More file actions
65 lines (41 loc) · 757 Bytes
/
booleans.py
File metadata and controls
65 lines (41 loc) · 757 Bytes
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
## Booleans
### Casting Booleans
bool(1)
bool(0)
bool(-1)
bool(1j)
bool(0.0)
bool(0j)
bool('True')
bool('False')
bool('')
bool([1,2])
bool({})
bool(None)
myList = [1,2]
if bool(myList):
print('Mylist has some values in it!')
a = 5
b = 5
if a - b:
print('a and b are not equal!')
a == b
### Boolean Logic
weatherIsNice = True
haveUmbrella = False
if not (haveUmbrella or weatherIsNice):
print('Stay inside')
else:
print('Go for a walk')
weatherIsNice = True
haveUmbrella = False
if (not haveUmbrella) and (not weatherIsNice):
print('Stay inside')
else:
print('Go for a walk')
weatherIsNice = True
haveUmbrella = False
if haveUmbrella or weatherIsNice:
print('Go for a walk')
else:
print('Stay inside')