-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex29.py
59 lines (40 loc) · 1.11 KB
/
ex29.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
"""
EC 1
The if-statement runs the code underneath it if the boolean expression
evaluates to True
EC 2
The code under an if-statement needs to be indented 4 spaces as
this is the way Python interprets a block of code. Instead of curly
braces, Python relies on indentation.
EC 3
If an if-statement's body isn't indented it's not considered part of an
the if-statement at all.
EC 4
Sure you can.
EC 5
If you change the variables then the comparisons in the if-statements
will evaluate differently possibly producing a different boolean value.
"""
# EC4
if 'sky' == 'tree':
print 'The world is insane.'
if 'sky' == 'sky':
print 'Sanity restored.'
people = 20
cats = 30
dogs = 15
if people < cats:
print "Too many cats! The world is doomed!"
if people > cats:
print "Not many cats! The world is saved!"
if people < dogs:
print "The world is drooled on!"
if people > dogs:
print "The world is dry!"
dogs += 5
if people >= dogs:
print "People are greater than or equal to dogs."
if people <= dogs:
print "People are less than or equal to dogs."
if people == dogs:
print "People are dogs."