Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

What is the result of the expression: print(2 ** 3 ** 2) ?

⚠ Common exam trap

The trap here is that many candidates assume exponentiation is left-associative like most other arithmetic operators, leading them to compute `(2 ** 3) ** 2 = 64` instead of the correct right-associative `2 ** (3 ** 2) = 512`.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

512

The expression `2 ** 3 ** 2` uses the exponentiation operator `**`, which in Python is right-associative. This means it is evaluated as `2 ** (3 ** 2)`, not `(2 ** 3) ** 2`. First, `3 ** 2` equals 9, then `2 ** 9` equals 512. Therefore, option A is correct.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    512

    Why this is correct

    Python's exponentiation operator `**` is right-associative, so `2 ** 3 ** 2` groups as `2 ** (3 ** 2)`, not `(2 ** 3) ** 2`. Evaluating the innermost exponent first gives `3 ** 2 = 9`, then `2 ** 9 = 512`. Left-associative evaluation would wrongly yield 64.

  • ✗

    256

    Why it's wrong here

    Exponentiation is right-associative, so 2 ** 3 ** 2 parses as 2 ** (3 ** 2) = 2 ** 9 = 512, not 256. The value 256 arises from treating it as (2 ** 3) ** 2, which is the left-associative reading Python does not apply here.

  • ✗

    64

    Why it's wrong here

    64 comes from evaluating (2 ** 3) ** 2 = 8 ** 2, but Python's ** operator groups right-to-left, giving 2 ** (3 ** 2) = 2 ** 9 = 512. Left-associative grouping applies to operators such as subtraction, not exponentiation.

  • ✗

    128

    Why it's wrong here

    128 has no derivation from 2 ** 3 ** 2; right-associative parsing yields 2 ** (3 ** 2) = 2 ** 9 = 512. Doubling 64 suggests misreading the exponent chain, whereas the actual rule nests the rightmost exponent first.

About these practice questions

Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.