HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Python Programming
  2. /Python Basics
  3. /Lists

Lists

Python Programming · Middle Stage (6–8) · 1 course, 15 worked problems, 36 practice questions

A list holds many values in order under one name, such as marks = [72, 65, 88]. Each item has an index that starts at 0, so marks[0] is 72 and marks[-1] is the last item. A list can change: .append() adds an item, .remove() takes one out, and you can replace an item by its index. A slice such as marks[1:3] gives part of a list. Functions like len(), sum(), max() and sorted() work on a whole list. With a loop, you can visit every item and process data such as readings from an experiment.

With practice you will be able to

  • Create a list and get items by index and by slice
  • Add, remove and change the items in a list
  • Find the total, mean and largest value in a list

On the syllabus of

  • CBSE / State Class 12
  • Python Certification
  • AP
  • IB
  • A-Level
  • IGCSE

Lessons

  • Lists: Many Values in One VariableAfter b = a, why does changing b also change a?Middle Stage (6–8)

Practice questions

Choose an answer, then check it. Each one shows a full explanation.

A program keeps each letter of a word once, in a list, and then puts a star into the list. letters = [] for ch in "level": if ch not in letters: letters.append(ch) letters.insert(1, "*") print(letters, len(letters)) What does the program print?

A list comprehension picks some words from a list and turns each one round. Then the program takes a slice of one result. words = ["sun", "moon", "star", "sky"] picked = [w[::-1] for w in words if "s" in w] print(picked, picked[1][1:]) What does the program print?

A program changes one item of a list and then reads from it. colours = ["red", "green", "blue", "pink"] colours[1] = "gold" print(colours[-1], len(colours), colours[1]) What does the program print?

A program puts a new number into a list with insert(), and then asks the list two questions. v = [2, 5, 2, 8] v.insert(2, 7) print(v.index(2), v.count(2), v) What does the program print?

Each step of a staircase is a different height. In one line, the program works out how much higher every step is than the step below it. v = [3, 7, 8, 12] rise = [v[i] - v[i - 1] for i in range(1, len(v))] print(rise, max(rise), len(rise)) What does the program print?

A program deletes a slice with a step from a list, and then adds one item. v = [7, 14, 21, 28, 35, 42] del v[::2] v.append(v[0] + v[-1]) print(v) What does the program print?

A function sorts the list it is given, and then returns a slice of it. The caller changes the slice. def top_two(scores): scores.sort(reverse=True) return scores[:2] marks = [55, 90, 72, 81] best = top_two(marks) best.append(0) print(marks[0], len(marks), best) What does the program print?

Some list methods change the list and give back None. A function such as sorted() gives back a new list instead. nums = [3, 1, 2] a = nums.sort() b = sorted(nums, reverse=True) c = nums.append(4) Which of these expressions are True after the code has run? Choose every correct option.

One or more options are correct. Tick all the correct ones: a wrong option costs marks, and a part-right answer earns part of the marks.

A function deletes an item of a list by its index, and returns the new length. It is called twice, and each result is printed on the same line. def remove_at(items, i): del items[i] return len(items) data = [10, 20, 30] print(remove_at(data, -1), end=" ") print(remove_at(data, 2), end=" ") print(data) What happens when the program runs?

A function builds a list from one column of a table that is a list of lists. Then the program changes both the new list and the table. def column(grid, k): return [row[k] for row in grid] g = [[1, 2, 3], [4, 5, 6]] c = column(g, 1) c[0] = 99 g[1][1] = 0 print(c, g[0][1]) What does the program print?

All 36 practice questions on Lists →

Worked problems

Each one has a hint, the key idea and a full worked solution.

  • The list is days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]…Easy
  • Find the positionEasy
  • The list is marks = [45, 78, 90, 62, 38, 85, 71]…Easy
  • What do a and b show at the end? Say it before you run it.Medium
  • Here is a table of marks: one row for each student, and one column for each test…Medium
  • For fruits = ["apple", "mango", "kiwi", "plum"], find fruits[0], fruits[-1], fruits[1:3] and…Easy
  • The list is ["milk", "rice", "tea"]. Add eggs at the end, remove milk, and put bread at the very…Easy
  • Put the marks [72, 85, 64, 90, 58] in order, first with the smallest first, then with the biggest…Easy
  • Find the total and the average of the marks 72, 85, 64, 90 and 58.Medium
  • Find the highest mark, the lowest mark and the difference between them for [72, 85, 64, 90, 58].Easy
  • A mark of 60 or more is a pass. How many of [72, 85, 64, 90, 58] passed?Medium
  • Build the list of the squares of 1 to 6: [1, 4, 9, 16, 25, 36].Medium

All 15 worked problems on Lists →

Python labs

  • Read and slice
  • Change the list
  • Pass or fail lists
  • Make a real copy
  • A multiplication table in lists
  • Project: the marks tracker

Related topics

  • Python Basics
  • Getting Started with Python
  • Variables and Data Types
  • Operators and Expressions
  • Input and Output
  • Strings
  • Conditionals: if, elif, else
  • Loops
  • Functions
  • Mini Projects