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

Question 21

Q458 - Operators


Evaluate the following Python arithmetic expression:


(3 * (1 + 2) ** 2 - (2 ** 2) * 3)


What is the result?


  • A

    3

  • B

    15

  • C

    13

  • D

    69

Reveal correct answer

Correct answer: B

Explanation

Topics: addition operator subtraction operator

             multiplication operator exponentiation operator

             parentheses operator precedence

Try it yourself:

Explanation:

The order of operator precedence here is:

Parantheses

Exponentiation operator

Multiplication operator

Subtraction operator


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

A. This choice does not correctly evaluate the given Python arithmetic expression. The result of the expression is not 3.

B. The expression follows the order of operations in Python, where parentheses are evaluated first, followed by exponentiation, multiplication, and subtraction. By calculating each part step by step, the result of the expression is 15.

C. This choice does not correctly evaluate the given Python arithmetic expression. The result of the expression is not 13.

D. This choice does not correctly evaluate the given Python arithmetic expression. The result of the expression is not 69.

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