What are A and B in programming?


#1

Question

What are A and B in programming?

Answer

In the graphic shown here we can think of A and B as statements.

In programming, a statement can be thought of as something that has some result. Take, for example, what we’ve been writing so far: 10 < 1 results in False, or (30 + 1) != 3 results in True.

So A and B are just statements like those, and they can be as complex as you want. Then we use and, or, and not as operators on these statements to make what we call expressions. An expression is just something that results in some value, True or False in this case.

If you want a challenge, take a look at the example below that’s a bit more than what we’ve done so far. If it doesn’t make sense, that’s totally fine! You will understand it in the exercises to come!

left_half  = (100 + 10) >= (20 - 5)  # True
right_half = (25 / 5) == 70  # False
bool_complex_false = left_half and right_half  # True AND False is False!

FAQ: Learn Python - Conditionals & Control Flow - To Be and/or Not to Be
#2

A and B here are Statements . Its generally known as “PREPOSITION”.
A preposition is an atomic sentence which can result either true or false and nothing else .
eg. A= its Sunny outside.
B= My father is not at home .
you can see the answers to the statement A and B can either be true or false and nothing else . In computer language the value given to A and B are 0(false) and 1(true). By these values we can form premises.


#3

Not to be overly semantic, this is a statement…

left_half  = (100 + 10) >= (20 - 5)

and this is an expression

(100 + 10) >= (20 - 5)

It is the expression that yields a value, not the statement, which only assigns the value to a variable.

result = A and B

Above, A and B represent expressions (which can also be literals), with and being the logical AND operating on the two operands.