Kit Library / Computer Science / Programming Fundamentals

⚡ Topic Learning Kit

List in python

English 20 leveled MCQs 17 flashcards Free

Shared by a Veda learner · Generated with Veda AI

Veda Bites

The whole idea, one bite at a time

Veda Bites are swipeable micro-lessons — each one teaches exactly one idea. The bites below come from this kit — swipe through them in the app.

💡 Key Idea

What is a Python List?

The Swiss Army knife of data.

A list in Python is an ordered, mutable collection of items. It can hold elements of different types (integers, strings, even other lists) and is defined using square brackets `[]`. Lists are zero-indexed, meaning the first element is at index `0`.

↳ A Python list is an ordered, changeable sequence written as a comma-separated list inside square brackets.

📖 Definition

List Creation

Start with empty or filled.

Create a list by placing items inside `[]` separated by commas. An empty list is simply `[]` or using the `list()` constructor.

↳ Use square brackets or the list() constructor to create a list.

💡 Key Idea

Indexing and Negative Indexing

Start at 0, end at -1.

Access items by their position. The first item has index `0`, the second `1`, and so on. Python also supports negative indexing, where `-1` refers to the last item, `-2` to the second last, etc.

↳ Use positive indices from the start (0) and negative indices from the end (-1).

✏️ Example

Slicing a List

Get a sublist quickly.

Use the slice syntax `[start:stop:step]` to extract a portion of the list. `start` is inclusive, `stop` is exclusive, and `step` is optional (default 1).

↳ Slicing returns a new list from the original using start:stop:step.

⚠️ Common Mistake

Index Out of Range

Don't go beyond the end.

↳ Check list length before accessing an index to avoid IndexError.

🛠️ Application

Modifying List Items

Lists are mutable—change them.

Since lists are mutable, you can change an item by assigning a new value to its index. You can also replace a slice with a new list.

↳ Assign to an index or slice to modify list contents in place.

⚙️ Process

Adding Items: append vs extend

One adds, one merges.

`append()` adds a single item to the end of the list. `extend()` adds all elements of an iterable (like another list) to the end.

↳ Use append() for one item, extend() to merge another list's items.

⚙️ Process

Removing Items: remove, pop, del

Three ways to delete.

`remove(x)` deletes the first occurrence of value `x`. `pop(i)` removes and returns the item at index `i` (default last). `del list[i]` deletes by index without returning.

↳ remove() by value, pop() by index (returns item), del by index.

⭐ Important Fact

List Length with len()

Count your items fast.

The built-in `len()` function returns the number of items in a list. It's O(1) — constant time — because Python stores the length internally.

↳ Use len(list) to get the number of elements quickly.

⚖️ Comparison

List vs Tuple

Mutable vs immutable.

↳ Lists are mutable and slower; tuples are immutable and faster.

✅ Best Practice

List Comprehensions

Build lists in one line.

A list comprehension provides a concise way to create lists. Syntax: `[expression for item in iterable if condition]`. It's often faster and more readable than a for loop.

↳ Use list comprehensions for clean, efficient list creation.

🧠 Memory Trick

Remember Index Start at 0

Zero is the first hero.

Think of a ruler: the first inch starts at 0, not 1. Similarly, Python lists start at index 0. Mnemonic: Zero-based Indexing = ZI.

↳ Always remember: first element = index 0.

🎯 Exam Tip

Common Exam: Reverse a List

Three ways to reverse.

To reverse a list, you can use: `list.reverse()` (in-place), slicing `[::-1]` (returns new list), or `reversed(list)` (returns iterator). Slicing is often tested.

↳ Use [::-1] to quickly reverse a list in exams.

❓ Did You Know

Lists Can Hold Mixed Types

Not just numbers!

Unlike arrays in many languages, Python lists can hold items of different data types in the same list, including other lists (nested lists).

↳ Lists are heterogeneous—they can store any data type.

Smart notes

What you'll study, topic by topic

1

Python Lists: Creation, Indexing, and Basic Operations

8 min

Python lists are ordered, mutable sequences defined with square brackets. They support indexing (including negative), slicing, and a variety of methods for adding, removing, and modifying items. List comprehensions offer…

  • Lists are created with square brackets `[]` and are zero-indexed.
  • Negative indexing starts from -1 (last item).
  • Slicing uses `[start:stop:step]` to extract sublists.

Full explanation, worked examples & memory tricks in the app

Leveled MCQ practice

Try the smart MCQs from this kit

All 20 questions, laddered from warm-up to topper-level, each with its answer and the reasoning behind it.

Warm-up · 12 questions

Q1. Which of the following correctly creates a list in Python?

Beginner
A list = {1, 2, 3}
B list = [1, 2, 3]
C list = (1, 2, 3)
D list = <1, 2, 3>

Answers and explanations are in the Veda app.

Q2. What is the index of the first element in a Python list?

Beginner
A 1
B 0
C -1
D None

Answers and explanations are in the Veda app.

Q3. Given `my_list = [10, 20, 30, 40]`, what does `my_list[-1]` return?

Beginner
A 30
B 40
C 20
D 10

Answers and explanations are in the Veda app.

Q4. What is the result of `len([1, 2, 3, 4])`?

Beginner
A 5
B 4
C Error
D 3

Answers and explanations are in the Veda app.

Q5. Which method adds an element to the end of a list?

Beginner
A extend()
B add()
C insert()
D append()

Answers and explanations are in the Veda app.

Q6. What does `[1, 2, 3] + [4, 5]` produce?

Beginner
A Error
B [1, 2, 3, 4, 5]
C [1, 2, 3, [4, 5]]
D [5, 7, 3]

Answers and explanations are in the Veda app.

Q7. What is the output of `[1, 2, 3] * 2`?

Beginner
A [1, 2, 3, 2]
B [1, 2, 3, 1, 2, 3]
C [2, 4, 6]
D Error

Answers and explanations are in the Veda app.

Q8. Lists in Python are immutable.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q9. The index `-1` always refers to the last element of a list.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q10. You can use the `+` operator to concatenate two lists.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q11. The method used to add an element to the end of a list is ___.

Beginner

Answers and explanations are in the Veda app.

Q12. To find the number of elements in a list, use the ___ function.

Beginner

Answers and explanations are in the Veda app.

Building up · 8 questions

Q13. Which of the following checks if 5 is in a list `nums`?

Intermediate
A nums.contains(5)
B in nums 5
C 5 in nums
D nums.has(5)

Answers and explanations are in the Veda app.

Q14. What does `[10, 20, 30, 40, 50][1:4]` return?

Intermediate
A [10, 20, 30, 40]
B [20, 30, 40, 50]
C [20, 30, 40]
D [10, 20, 30]

Answers and explanations are in the Veda app.

Q15. What is the result of `[1, 2, 3].pop()`?

Intermediate
A 1
B None
C 3
D [1, 2]

Answers and explanations are in the Veda app.

Q16. Which of the following removes the first occurrence of a value from a list?

Intermediate
A delete()
B discard()
C pop()
D remove()

Answers and explanations are in the Veda app.

Q17. What is the output of `[x*2 for x in [1, 2, 3]]`?

Intermediate
A Error
B [1, 2, 3]
C [2, 4, 6]
D [3, 6, 9]

Answers and explanations are in the Veda app.

Q18. The `insert()` method adds an element to the end of a list.

Intermediate
A True
B False

Answers and explanations are in the Veda app.

Q19. Slicing a list always returns a new list.

Intermediate
A True
B False

Answers and explanations are in the Veda app.

Q20. A list can contain elements of different data types; this property is called ___.

Intermediate

Answers and explanations are in the Veda app.

Flashcards

Tap a card to flip it

17 flashcards in this kit — the app reviews them with spaced repetition so the right card returns on the right day.

Study it properly — free, in the app

The full Veda Bites deck, complete notes, spaced-repetition flashcards, leveled MCQs, tests and games for this kit — plus Daily Facts and the Arena, every day.