-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes-if.txt
43 lines (37 loc) · 912 Bytes
/
notes-if.txt
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
.--------------------------.
| November 12, 2016 |
| Conditional statements |
| If / Else |
'--------------------------'
# Comparison Operators:
==
!=
>
<
>=
<=
# Format! Statements that are indented are operated on
# as a result of the expression's validity.
if expression:
statement
statement
statement
if expression: # nesting!
statement
elif expression: # optional
statement
statement
statement
else expression: # optional
statement
statement
statement
outside conditional
# Concatenation. Consider the following nested loop. Nesting is great, but
# if it gets out of hand it can make managing code difficult.
if a == 10:
if b == 20:
if c == 30:
print("c is 30")
if (a == 10) and (b == 20) and (c == 30): # accomplishes the same thing but
print("c is 30") # is easier to read or manage.