Worksheets › Class 9 › Python Lists › Cheat sheet

Class 9 Python Lists: cheat sheet

CBSE Computational Thinking and AI. A list holds many values in order. Items are found by index (from 0, or from −1 at the end), sliced, changed with methods and summed up with functions.

Open the printable cheat sheetPractice worksheet

Key ideas

Remember

a = [10, 20, 30, 40, 50]a[0] = 10, a[3] = 40, a[-1] = 50
Slicesa[1:3] = [20, 30]; a[:2] = [10, 20]; a[-3:-1] = [30, 40]
Functionslen(a) = 5, sum(a) = 150, max(a) = 50
Methodsa = [5, 2, 8] a.append(1) # [5, 2, 8, 1] a.insert(0, 7) # [7, 5, 2, 8, 1] a.remove(2) # [7, 5, 8, 1] a.pop() # [7, 5, 8]

Watch out

Worked example

num = [19, 77, 41, 66, 54, 51]. What is printed by (a) print(len(num)) (b) print(num[1:4]) (c) print(num[-4:-1])? For (b) and (c), write the items separated by commas.

Working: num[1:4] is the 2nd to 4th items; num[-4:-1] is the 3rd to 5th

Answer: (a) 6; (b) 77, 41, 66; (c) 41, 66, 54

Practise Python Lists

Revise with this page, then practise: every Python Lists sheet in the app is new, with an answer key and working.

Coming soon for Android and iPhone.