forked from CodeMouse92/DeadSimplePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboolean_identity_operators.py
More file actions
32 lines (21 loc) · 874 Bytes
/
boolean_identity_operators.py
File metadata and controls
32 lines (21 loc) · 874 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
spam = True
eggs = False
potatoes = None
if spam is True: # Evaluates to True
print("We have spam.")
if spam is not False: # Evaluates to True
print("I DON'T LIKE SPAM!")
if spam: # Implicitly evaluates to True (preferred)
print("Spam, spam, spam, spam...")
if eggs is False: # Evaluates to True
print("We're all out of eggs.")
if eggs is not True: # Evaluates to True
print("No eggs, but we have spam, spam, spam, spam...")
if not eggs: # Implicitly evaluates to True (preferred)
print("Would you like spam instead?")
if potatoes is not None: # Evaluates to False (preferred)
print("Yum") # We never reach this...potatoes is None!
if potatoes is None: # Evaluates to True (preferred)
print("Yes, we have no potatoes.")
if eggs is spam: # Evaluates to False (CAUTION!!!)
print("This won't work.")