BAMS

11th Grade Python Practice: Questions, Answers and Tips

Looking for 11th grade python practice? Below are worked examples, the mistakes students make most, and practice questions with an answer key.

5 min read

In this article

Looking for 11th grade python practice? Below are worked examples, the mistakes students make most, and practice questions with an answer key.

Every example below comes from BAMS Academy's Python practice, the same questions students answer on the site.

Python in 11th grade, skill by skill

Functions, data structures, and object-oriented Python. BAMS Academy breaks the unit into the skills below (part of all 11th grade computer science topics). Each comes with one of its practice questions.

Use and trace Python lists, dicts, sets, slices and comprehensions

You need a built-in type that stores unique values with no defined order. Which one? (Choices: dict; set; tuple; list.)

Answer: set. A set stores unique values with no defined order.

Evaluate the Python expression. Print(len({1, 2, 2, 3, 3, 3})) (Choices: 3; 6; 2; 1.)

Answer: 3. A set stores each distinct value once, so {1, 2, 2, 3, 3, 3} holds just 1, 2 and 3.

Reason about Python functions, defaults, scope and argument packing

A code reviewer asks: Why should a function do one thing? (Choices: The caller can then use the result rather than only see it; None; It is easier to name, test and reuse; It is created once and shared between calls.)

Answer: It is easier to name, test and reuse. Why should a function do one thing? It is easier to name, test and reuse.

What does a function return if it has no return statement? (Choices: It is created once and shared between calls; The caller can then use the result rather than only see it; It is easier to name, test and reuse; None.)

Answer: None. What does a function return if it has no return statement? None.

Reason about Python classes, instances, inheritance and overriding

What does this print? Class Dog: def __init__(self, name): self.name = name def speak(self): return f"{self.name} says woof" print(Dog("Rex").speak()) (Choices: Raises a TypeError about self; Dog says woof; self.name says woof; Rex says woof.)

Answer: Rex says woof. __init__ stores name on the instance, and calling speak() passes that instance as self automatically.

Trace the class behaviour and give the output. Class Animal: def speak(self): return "..." class Cat(Animal): def speak(self): return "meow" print(Cat().speak()) (Choices: ... meow; Raises a TypeError for redefining speak; meow; ...)

Answer: meow. Cat overrides speak, and Python looks at the instance's own class first, so the subclass version runs.

Worked examples

Example 1

Question: Which Python type represents a sequence of characters?

  1. tuple
  2. set
  3. list
  4. str

How to solve it: A str represents a sequence of characters.

Answer: str

Why the other choices don't work:

  • A student who picks "tuple" usually chose tuple, which has different behaviour.
  • A student who picks "set" usually chose set, which has different behaviour.
  • A student who picks "list" usually chose list, which has different behaviour.

Example 2

Question: You need a built-in type that represents a whole number. Which one?

  1. tuple
  2. int
  3. set
  4. list

How to solve it: A int represents a whole number.

Answer: int

Why the other choices don't work:

  • A student who picks "tuple" usually chose tuple, which has different behaviour.
  • A student who picks "set" usually chose set, which has different behaviour.
  • A student who picks "list" usually chose list, which has different behaviour.

Common mistakes to watch for

  • Question: What does this print? Nums = [1, 2, 3, 4, 5] print(nums[1:4]) (Choices: [2, 3, 4, 5]; [1, 2, 3]; [1, 2, 3, 4]; [2, 3, 4].)

    Answer: [2, 3, 4].

    A student who picks "[1, 2, 3]" usually reads the indexes as a count rather than start and stop positions.

  • Question: Evaluate the Python expression. d = {"a": 1, "b": 2} d["a"] = 5 d["c"] = 3 print(sum(d.values())) (Choices: 6; 10; 3; 11.)

    Answer: 10.

    A student who picks "11" usually adds the replaced value 1 as well as the new value 5.

  • Question: Evaluate the Python expression. Print([x * x for x in range(5) if x % 2 == 1]) (Choices: [0, 1, 4, 9, 16]; [0, 4, 16]; [1, 3]; [1, 9].)

    Answer: [1, 9].

    "[1, 3]" is a tempting wrong answer — filters correctly but returns the values instead of their squares.

  • Question: You need a built-in type that stores unique values with no defined order. Which one? (Choices: dict; set; tuple; list.)

    Answer: set.

    A student who picks "dict" usually chose dict, which has different behaviour.

  • Question: Evaluate the Python expression. Print(len({1, 2, 2, 3, 3, 3})) (Choices: 3; 6; 2; 1.)

    Answer: 3.

    A student who picks "6" usually counts every literal element, forgetting that a set discards duplicates.

  • Question: A code reviewer asks: Why should a function do one thing? (Choices: The caller can then use the result rather than only see it; None; It is easier to name, test and reuse; It is created once and shared between calls.)

    Answer: It is easier to name, test and reuse.

    A student who picks "The caller can then use the result rather than only see it" usually answered "The caller can then use the result rather than only see it", which is sound Python advice but not the answer here.

Try these practice questions

  1. What does this print? Nums = [1, 2, 3, 4, 5] print(nums[1:4])

    1. [2, 3, 4, 5]
    2. [1, 2, 3]
    3. [1, 2, 3, 4]
    4. [2, 3, 4]
  2. Evaluate the Python expression. d = {"a": 1, "b": 2} d["a"] = 5 d["c"] = 3 print(sum(d.values()))

    1. 6
    2. 10
    3. 3
    4. 11
  3. Evaluate the Python expression. Print([x * x for x in range(5) if x % 2 == 1])

    1. [0, 1, 4, 9, 16]
    2. [0, 4, 16]
    3. [1, 3]
    4. [1, 9]
  4. Which Python type stores key-to-value pairs for fast lookup by key?

    1. set
    2. tuple
    3. dict
    4. list
Answer key
  1. [2, 3, 4] — A slice includes the start index and excludes the stop index, so [1:4] gives positions 1, 2 and 3.
  2. 10 — Assigning to an existing key replaces its value, so the dict is {"a":5, "b":2, "c":3} and the values sum to 10.
  3. [1, 9] — Range(5) gives 0-4, the condition keeps 1 and 3, and the expression squares them to 1 and 9.
  4. dict — A dict stores key-to-value pairs for fast lookup by key.

Keep practicing

The fastest way to build confidence is a few questions at a time, with feedback on each answer. Start with Python practice for grade 11, where every question comes with a step-by-step explanation.

More from BAMS Academy:

Share

Ready to practice?