Ask Question
28 July, 01:26

Put these expressions in a small program that will demonstrate whether they are true or false. Paste the code, and output from the program into your submission. Use if statements and output a message indicating that the expression is True or False.

+3
Answers (1)
  1. 28 July, 02:38
    0
    complete question:

    Put these expressions in a small program that will demonstrate whether they are true or false. Paste the code, and output from the program into your submission. Use if statements and output a message indicating that the expression is True or False.

    a = 5, b = 4, c = 3, d = 2;

    (a < = b + 1)

    (a b)

    (a > = c || d > = 5)

    (! (a > b))

    (b > = a &&! (d < b))

    Answer:

    a = 5

    b = 4

    c = 3

    d = 2

    if a < = b + 1:

    print ("True")

    else:

    print ("False")

    if a b:

    print ("True")

    else:

    print ("False")

    if a > = c or d > = 5:

    print ("True")

    else:

    print ("False")

    if not (a > b):

    print ("True")

    else:

    print ("False")

    if (b > = a and not (d < b)):

    print ("True")

    else:

    print ("False")

    Explanation:

    I used python to write the code

    The equivalent of && in python is and while the equivalent of || is or. The equivalent of! is not in python.

    I wrote an if statement to print True for each expression if it is actually true and the else statement print False if the expression is actually false.

    For example the first expression says if a is less than or equal to b + 1 (5). This statement is actually true so the expression will print True. a is 5 and b plus 1 is 5, so a is equal to 5 which is true.

    if a b:

    Both expression must be true for the if statement to print True. a is not less than b and c is not greater than b so the expression amount to False.

    if a > = c or d > = 5:

    One expression must be true for the expression to be True. a > = c is true and d > = 5 is false. So the expression amount to True.

    not (a > b)

    This simply means negate the statement a > b. This gives False.

    (b > = a and not (d < b))

    b > = a is false

    d < b is true

    not (d < b) is false

    false and false is definitely False
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Put these expressions in a small program that will demonstrate whether they are true or false. Paste the code, and output from the program ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers