logo

AQA A-Level Computer Science practice

Which expression tests whether the list xs is empty?

Try the question first, then check the answer and practise the same topic again.

At a glance

MCQ

Type

practice

Style

Topic

Lists in functional programming

Exam-style question

Try this first

Which expression tests whether the list xs is empty?.

  1. A.xs == []
  2. B.xs == [0]
  3. C.len(xs) == 1
  4. D.xs[0] == []

Answer and explanation

Concise answer

xs == []

Why this is correct

The expression xs == [] is true exactly when xs contains no elements.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions