216k views
3 votes
In computer programming, what is a conditional?

User BruneauB
by
5.0k points

2 Answers

5 votes

Conditionals essentially test for true and false.

For instance, in python:

if 1 > 0:

the code does something.

Since 1 is greater than 0 the conditional is true, but if the if statement is false, for instance:

if 1 < 0:

the code does something

else:

the code does something else

The if statement is skipped because 1 is not less than 0 and the else statement runs.

User Alex VII
by
5.3k points
5 votes

Answer:

In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition.

Step-by-step explanation:

Conditional (computer programming) In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.

User Paul Cantrell
by
4.2k points