Operators and Precedence

39 MCQs Covers arithmetic, comparison, assignment and logical operators. Also covers precedence, evaluating expressions and code-output questions

MCQs

39 questions · 35 min · 39 marks

Want to try first? Take the free Computer Science test: SDLC and Waterfall Model

Sample questions

The first 5 of 39. Try each one, then tap to see the answer.

  1. Question 1

    What is the value of 10 % 3 in Python?

    • A3
    • B1
    • C0
    • D10
    Show answer

    Answer: B

    % gives the remainder: 10 = 3×3 + 1.

  2. Question 2

    What does the ** operator do in Python?

    • AModulus
    • BDivision
    • CFloor division
    • DExponentiation
    Show answer

    Answer: D

    ** raises the first number to the power of the second.

  3. Question 3

    What is the result of the expression 3 + 2 * 5 in Python?

    • A13
    • B25
    • C15
    • D30
    Show answer

    Answer: A

    Multiplication has higher precedence: 2 * 5 = 10, then 3 + 10 = 13.

  4. Question 4

    Which of the following is a comparison operator?

    • Aand
    • B+
    • C==
    • D=
    Show answer

    Answer: C

    == compares two values; = assigns and 'and' is logical.

  5. Question 5

    What does a += 5 mean?

    • Aa = a * 5
    • Ba = a + 5
    • Ca = a - 5
    • Da = 5
    Show answer

    Answer: B

    += adds the right side to the variable and stores the result.

More tests in Python Programming

Practise with a free account

Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.

Create free account