Control Structures of Programming (1)
Control Structures of Programming (1)
Artificial Intelligence
Ch: 5 Introduction to
Control Structures
Prolog
Have breakfast
Go to school
2. Conditional Control (Selection)
Definition: Conditional control allows programs to make decisions based on specific conditions.
Types of Conditional Statements:
If Statement
1 Executes code if condition is true
If-Else Statement
2 Provides alternative path if condition is false
Else-If Ladder
3 Checks multiple conditions in sequence
Continue Statement
Skips current iteration and moves to the next one.
Example
for i in range(10):
if i == 5:
break
print(i)
Summary
Sequential Conditional
Branching Iterative
Practice using different control structures in simple programs to understand how they help in problem-solving.
Thank You !