PCAP 31 03 PCAP Certified Associate Python Programmer · Free Practice Question Medium

Question 27

Q438 - Control Flow


What would you insert instead of ???

so that the program prints TRUE to the monitor?



  • A

    a > b

  • B

    a <= b

  • C

    a < b

  • D

    a == b

Reveal correct answer

Correct answer: A

Explanation

Topics: if else addition operator multiplication operator

             division operator  operator precedence boolean

Try it yourself:

Explanation:

The operators here come from two different groups:

The group "Multiplication, Division, Floor division, Modulus"

has a higher precedence than the group

"Addition, Subtraction".

Meaning multiplication or division come before addition.

The other topic here is calculating with a boolean

If you calculate with a boolean then True will become 1 and False will become 0


Q438 (Please refer to this number, if you want to write me about this question.)

A. The expression "a > b" compares the value of variable 'a' (result of w + x * y) with the value of variable 'b' (result of w + x / z). If 'a' is greater than 'b', the condition is true, and the program will print 'TRUE' to the monitor.

B. The expression "a <= b" checks if the value of variable 'a' is less than or equal to the value of variable 'b'. This comparison is not suitable for ensuring that the program prints 'TRUE' to the monitor in this specific scenario, making this choice incorrect.

C. The expression "a < b" compares the value of variable 'a' with the value of variable 'b' to check if 'a' is less than 'b'. In this case, the condition needs to evaluate to true for the program to print 'TRUE', so this choice is incorrect as it does not guarantee the desired outcome.

D. The expression "a == b" checks if the value of variable 'a' is equal to the value of variable 'b'. Since 'a' and 'b' are calculated using different operations (multiplication and division), they are unlikely to be equal in this context, so this choice is incorrect.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need