-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathif_elif_else.py
More file actions
18 lines (16 loc) · 803 Bytes
/
Copy pathif_elif_else.py
File metadata and controls
18 lines (16 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""The syntax of an "if-elif-else"-statement in Python."""
if booleanExpression 1:
conditional 1 statement 1 # Only executed if booleanExpression 1
conditional 1 statement 2 # evaluates to True.
# ...
elif booleanExpression 2: # such block can be placed arbitrarily often
conditional 2 statement 1 # Only executed if booleanExpression 1
conditional 2 statement 2 # evaluates to False and
# ... # booleanExpression 2 evaluates to True.
else: # The else-paart is optional, can be left away.
alternative statement 1 # Only executed if booleanExpression 1 and
alternative statement 2 # 2 both evaluate to False.
# ...
normal statement 1 # Always executed, regardless of the result of
normal statement 2 # booleanExpression 1 and 2.
# ...