ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Arithmetic/Powers, order and incrementing
J277 · 2.2.1

Unit 5 · Lesson 3

Powers, order and incrementing

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Evaluate expressions in the correct order and update a variable without overwriting it incorrectly.

ERL uses ^ for exponentiation; Python uses **. Expressions follow an order: brackets, powers, multiplication/division/DIV/MOD, then addition/subtraction. Multiplication/division and addition/subtraction ties work left to right; chained Python powers are the exception and group from the right. To increment safely, calculate from the old value and assign back: score = score + 1.

Exponentiation

Raising one number to the power of another.

Precedence

Rules that decide which operator in an expression is evaluated first.

Brackets

Symbols used to make part of an expression evaluate before the surrounding operations.

Increment

Increasing a stored number, often by one, and saving the new value.

Keep these in mind

  • ERL ^ maps to Python **.
  • Brackets can override the normal order of operations.
  • Powers are evaluated before multiplication, which is evaluated before addition.
  • score = score + 1 reads the old score and stores the new one.

Learning objective

Evaluate expressions in the correct order and update a variable without overwriting it incorrectly.

Exam tip

Write down each intermediate result when tracing a long expression. Apply brackets and powers before moving to multiplication and addition.

Common mistake

score =+ 1 assigns positive 1 and score + 1 stores nothing. Use score = score + 1 or Python's score += 1.

PreviousNext