
The Sele c tion Program Structure 79
Each block of statements is executed when that particular path of logic
is selected. This selection depends on the conditions in the multiple-path if
statement that are evaluated from top to bottom until one of the conditions
evaluates to True. The eli f parts and the else part are o ptional. The following
example shows the if statement with several paths.
print "Testing multi-path selection in a Python script"
y = 4.25
x = 2.55
if y > 15.50 :
x = x + 1
print "x: ", x
elif y > 4.5 :
x = x + 7.85
print "x: ", x
elif y > 3.85 :
x = y * 3.25
print "x: ", x
elif y > 2.98 :
x = y + z*454.7
print "x: ", x
else :
x = y
print "x: ", ...