4. if
/ else
¶
What to do when the
if
condition is false?.The
else
clause means otherwise.It is usually used to indicate complementary conditions.
The if / else conditions can be seen as a car arriving at a fork in the road.
Depending on the result of a condition, the car can take the upper or lower road.

The two codes below do the same thing but one uses if / else conditions.
Print output (drag lower right corner to resize)
|
Activity: CodeLens 4.1 (cl_l10_4a_en)
Print output (drag lower right corner to resize)
|
Activity: CodeLens 4.2 (cl_l10_4b_en)
You have attempted 1 of 2 activities on this page