-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathif_statements.py
More file actions
38 lines (29 loc) · 736 Bytes
/
if_statements.py
File metadata and controls
38 lines (29 loc) · 736 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
#Python control flows - If statement
'''
Python uses the usual flow control statements known
from other languages, with some twists.
Perhaps the most well-known statement type is the
if statement.
Think of an if statement as a way to check to see if
conditions are met!
If a condition is met, do something...
else do something different!
'elif' stands for 'else if'
both elif and else are optional!
Note: I will be defining a function to demo :)
'''
#The basics
def number_play(x):
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
elif x == 1:
print('Single')
else:
print('More')
number_play(-1)
number_play(0)
number_play(1)
number_play(2)