-
Notifications
You must be signed in to change notification settings - Fork 0
/
if_else.py
61 lines (42 loc) · 1.21 KB
/
if_else.py
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
"""
A python program about if/else statements.
"""
is_male = False # Boolean variables
is_tall = True
if is_male or is_tall:
print('You are a male or tall or both')
else:
print('You are neither male nor tall')
is_male = False # Boolean variables
is_tall = False
if is_male and is_tall:
print('You are a tall male')
else:
print('You are neither male nor tall')
is_male = True # Boolean variables
is_tall = False
if is_male and is_tall:
print('You are a tall male')
elif is_male and not is_tall:
print('You are a short male')
else:
print('You are neither male nor tall')
is_male = False # Boolean variables
is_tall = True
if is_male and is_tall:
print('You are a tall male')
elif is_male and not is_tall:
print('You are a short male')
elif not is_male and is_tall:
print('You are a not male but are tall')
else:
print('You are neither male nor tall')
# Comparison statements (for example: >, <, >=, <=, ==, !=)
def max_num(num1, num2, num3):
if num1 >= num2 and num1 >= num3:
return num1
elif num2 >= num1 and num2 >= num3:
return num2
else:
return num3
print(max_num(5, 9, 7))