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

Question 9

What will be the result of the following expression ?

2//3 ** 2

  • A

    5

  • B

    2

  • C

    4

  • D

    0

Reveal correct answer

Correct answer: D

Explanation

Let's break down the expression 2 // 3 ** 2 step by step:


  1. Exponentiation: 3 ** 2 equals 9.

  2. Floor Division: 2 // 9 performs floor division of 2 by 9, resulting in 0 (the largest integer less than or equal to the division result).

Therefore, the result of the expression 2 // 3 ** 2 is 0.


In Python, the order of operations follows PEMDAS rule:

1. Parentheses (()): Expressions inside parentheses are evaluated first.

2. Exponents (**): Exponentiation is performed next.

3. Multiplication (*) and Division (/): Multiplication and division are evaluated from left to right.

4. Addition (+) and Subtraction (-): Addition and subtraction are evaluated from left to right.

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