PCEP 30 02 PCEP Certified Entry Level Python Programmer · Free Practice Question Easy

Question 12

What will be the output of the code after Execution ?

x = 15

y = 10

z = 5

if x > y:

    if y > z:

        result = "A"

    else:

        result = "B"

else:

    result = "C"

print(result)

  • A

    B

  • B

    A

  • C

    Nothing will be printed

  • D

    C

Reveal correct answer

Correct answer: B

Explanation

The outer if statement (if x > y:) is true because x (15) is greater than y (10).

The inner if statement (if y > z:) is also true because y (10) is greater than z (5).

Therefore, the value of 'result' is set to "A" in this case.

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