17-29
9. Sample Scripts
Sample 1: Conditional Branching
Purpose
With conditional branching a condition is evaluated and then
processing follows one of multiple paths in accordance with
the evaluation result.
The example below is for a simple “if... else...” statement.
Description
a=int(input("a="))
Accepts user input while the py script is running.
Input values are converted to integers and define variable a.
if a<5: If the variable a is less than 5,
print("a<5") outputs the text string a<5.
else: Otherwise (if variable a is 5 or greater),
print("a>=5") outputs the text string a>=5.
Execution Result (when a=1 and a=10 are input)
(1) If you input a = 1 (2) If you input a = 10
b ba
w w