86.0k views
5 votes
Tests a series of Boolean expressions and execute corresponding block when it finds one that is true, is known as what?

1 Answer

4 votes

Final answer:

A construct that tests Boolean expressions and executes a corresponding block when one evaluates to true is known as a conditional or if-else statement, which is essential for decision making in programming.

Step-by-step explanation:

The construct that tests a series of Boolean expressions and executes a corresponding block when it finds one that is true is known as a conditional statement or an if-else statement. In programming, these statements are used to control the flow of execution based on certain conditions. They are a fundamental part of decision making in code. For example, in Python, it looks like this:

if condition1:
# execute block 1
elif condition2:
# execute block 2
else:
# execute block 3 if none of the above conditions are true

The if statement evaluates condition1, and if it's true, it executes block 1. If condition1 is false, it moves to elif (which stands for "else if") and evaluates condition2, and this process continues. If none of the conditions are met, the else block is executed as the default case.

User Ashish Singh Rawat
by
8.1k points