BORING EDUCATION — LIVE EXPERIMENTProduct is live. Experiments are running. Feedback is being collected. Improvements are underway.Welcome to Boring Education. We're glad you're here while we're figuring out how to make learning better.
BORINGEDUCATION

Python Operators and Expressions: PECTAA Class 11 Computer Science, Punjab Board

23 October 2026

Is 10 / 3 the same as 10 // 3 in Python? No: one gives 3.3333333333333335 and the other gives 3. Small symbols make big differences, and Python follows strict rules about which operation happens first. Section 2.3 of the book covers all of it.

Chapter 2 of the PECTAA Computer Science 11 book is Python Programming. After variables, data types and input/output (section 2.2), section 2.3 covers operators and expressions: arithmetic, comparison, assignment and logical operators, expressions, and operator precedence. This note is for FSc Part 1 (1st year, Class 11) students in Lahore, Faisalabad, Sargodha, Rawalpindi, Multan, Gujranwala and the other Punjab boards. Gujrat district comes under the Gujranwala board. PECTAA writes the books. Your own board sets your paper.

What to know

Arithmetic operators (section 2.3.1). For a = 10 and b = 3:

Operator Meaning Result
+ addition 13
− subtraction 7
* multiplication 30
/ division (always a float) 3.3333333333333335
// floor division 3
% modulus (remainder) 1
** exponentiation 1000

Comparison operators (section 2.3.2). They compare two values and return True or False. For x, y = 10, 5: x > y is True, x < y is False, x == y is False, x != y is True, x >= y is True, x <= y is False. Note that == compares, while = assigns.

Assignment operators (section 2.3.3). = assigns the value on the right to the variable on the left. Compound operators combine arithmetic with assignment: a += b means a = a + b, and likewise -=, *=, /=, %= and **=.

Logical operators (section 2.3.4). and, or and not combine conditions and return Boolean values. With x = True and y = False: x and y is False, x or y is True, not x is False.

Expressions (section 2.3.5). An expression is a combination of variables, operators and values that produces a result. 3 + 4 gives 7; (3 + 4) * 2 gives 14, because parentheses control the order.

Operator precedence (section 2.3.6). Python, like mathematics, evaluates some operators before others:

  1. Parentheses () first: (3 + 2) * 4 = 20.
  2. Exponentiation ** next: 2 ** 3 = 8.
  3. *, /, % (and //) next: 4 * 3 = 12, 10 / 2 = 5.0, 11 % 3 = 2.
  4. + and − last: 5 + 2 = 7, 10 − 4 = 6.

The book's tip: parentheses make complex expressions clearer and force the order you want.

Key points

  • / always gives a float; // drops the fractional part.
  • Comparison and logical operators give True or False.
  • a op= b is short for a = a op b, and it changes a each time.
  • Precedence: parentheses → ** → * / // % → + −.

Worked examples

Example 1 (book Class Activity). Evaluate 10 + 3 * 2 ** 2 − 5 / 5.

  1. 2 ** 2 = 4.
  2. 3 * 4 = 12 and 5 / 5 = 1.0.
  3. 10 + 12 − 1.0 = 21.0 (a float, because / was used).

Example 2 (book Class Activity). Evaluate (10 + 3) * (2 ** (2 − 1)) / 5.

  1. Inner brackets: 10 + 3 = 13 and 2 − 1 = 1, so 2 ** 1 = 2.
  2. 13 * 2 = 26, then 26 / 5 = 5.2.

Example 3 (book assignment code, run in order). Start with a = 10, b = 5, and run each line one after another:

  1. a += b → 15
  2. a -= b → 10
  3. a *= b → 50
  4. a /= b → 10.0
  5. a %= b → 0.0
  6. a **= b → 0.0

The book's comments print 5, 2.0, 2 and 100000 for steps 2, 4, 5 and 6. Those values do not follow from running the lines in sequence; the list above is what Python actually prints.

Example 4 (comparison with logic). A student scores marks = 72. Evaluate marks >= 50 and marks < 80.

  1. marks >= 50 is True.
  2. marks < 80 is True.
  3. True and True gives True, so the student is in the 50 to 79 band.
  4. If marks were 85, the second test would be False, and the whole expression would be False.

Common mistakes in the exam

  1. Writing two assignments with a comma. a= 10, b=3 is a SyntaxError. Use a = 10 and b = 3 on separate lines, or a, b = 10, 3.
  2. Confusing = with ==. = assigns; == compares.
  3. Expecting 10 / 2 to give 5. It gives 5.0.
  4. Ignoring precedence. 2 + 3 * 4 is 14, not 20.
  5. Using an undefined name. In the book's logical NOT code, the result is stored as logical_not_x but printed as logical_not, which raises a NameError; print logical_not_x.

Exam technique

  • For output questions, trace each line and keep track of every variable's current value.
  • Show precedence steps one operator at a time.
  • Write True and False with capital letters and no quotes.
  • Check your board's notice for the sections in your paper.

Practice questions

  1. What is 17 // 5 and 17 % 5? Answer: 3 and 2.
  2. What does print(4 == 4.0) show? Answer: True.
  3. What is not (5 > 3)? Answer: False.
  4. Evaluate 2 + 3 * 4 ** 2. Answer: 4 ** 2 = 16, 3 * 16 = 48, 2 + 48 = 50.
  5. x = 7; x *= 2; x -= 4. What is x? Answer: 14, then 10.

Ready to practise this? Continue in 1st Year Computer Science.

Quick answers

What is the difference between / and // in Python?

/ is true division and always gives a float: 10 / 3 = 3.3333333333333335. // is floor division: 10 // 3 = 3.

What does the % operator do?

It gives the remainder (modulus): 10 % 3 = 1 and 11 % 3 = 2.

What do comparison operators return?

A Boolean value, True or False. For x = 10 and y = 5, x > y is True and x == y is False.

What is the order of operator precedence in Python?

Parentheses first, then exponentiation (**), then *, /, // and %, then + and −. So 10 + 3 * 2 ** 2 − 5 / 5 = 21.0.

Which board sets my paper if I study in Gujrat?

Gujrat district is listed under the Board of Intermediate and Secondary Education, Gujranwala. PECTAA writes the books. Your board sets the paper and the dates, so follow its notices.

Learn this properly, step by step, free.

Continue in 1st Year Computer Science

Free right now. No ads. Tell us what to fix.

More notes

All notes →