Lists
NCERT Class 11 Computer Science Chapter 9: Lists (Pages 189–206)
Lists at a Glance
CBSE
Class 11
Computer Science
Computer Science
9
189–206
6 study resources
Lists is a chapter in the CBSE Class 11 Computer Science syllabus from Computer Science. This chapter hub brings together revision notes, practice questions, worksheets, flashcards to help students learn, practice, and revise Lists effectively.
Scroll down to find Lists notes, practice questions, worksheets, and revision resources — all in one place. Use the sidebar to jump to any section, or browse the full page below.
NCERT Class 11 Computer Science Chapter 9: Lists (Pages 189–206)
CBSE
Class 11
Computer Science
Computer Science
9
189–206
6 study resources
Download the Lists revision guide with key points, summaries, and quick revision notes for CBSE Class 11 Computer Science.
Key Points
Definition of a List
A list is an ordered, mutable sequence of elements, enclosed in [].
Accessing Elements
Elements can be accessed by indices starting from 0, e.g., list[0] for the first element.
Lists are Mutable
Lists can be modified after creation, allowing for updates to their content.
Concatenation with +
Combine lists using +, e.g., list1 + list2 results in a new list combining both.
Repetition with *
Replicate lists using *, e.g., list * n creates a new list with repeated elements.
Membership Testing
'in' and 'not in' test for element presence, returning True or False.
Slicing Lists
Extract sublists using slicing, e.g., list[start:end] retrieves elements from start to end-1.
List Length
Use len(list) to get the number of elements in a list.
Common List Methods
Methods such as append(), insert(), remove(), and pop() allow for diverse list manipulations.
Sorting and Reversing
Use sort() to arrange elements, and reverse() to flip their order.
Creating Nested Lists
Lists can contain other lists, which allows for multi-dimensional data structures.
Copying Lists
Copy a list using slicing (list2 = list1[:]) or the list() function to avoid reference issues.
List as Function Arguments
Passing lists to functions allows for mutations within the function, as they are passed by reference.
Index Errors
Accessing out-of-range indices results in IndexError; validate index before usage.
TypeError on Concatenation
Only lists can be concatenated with +; mixing types results in TypeError.
Finding Maximum/Minimum
Use max() and min() to find the largest and smallest elements in a list.
List Sorting (Built-in)
sort() sorts a list in-place, while sorted() returns a new sorted list without modifying the original.
Iterating Over Lists
Use for loops for straightforward traversal of list elements.
Deleting Elements
Elements can be removed via remove(value) or pop(index), affecting the list size.
Using List Comprehensions
Create modified lists efficiently using list comprehensions for filtering and mapping.
Common Errors
Be wary of modifying lists while iterating, as it can lead to unexpected behavior.
Practice important questions and exam-style problems from Lists. These questions cover key topics from the CBSE Class 11 Computer Science syllabus.
How to practice: Start with the questions below to test your understanding of Lists. Use the revision guide to review concepts you find difficult, then come back and retry the questions for better retention.
What is the main feature of a list in Python?
Which of the following correctly initializes a list containing mixed data types?
How is the first element of a list accessed in Python?
What will the code list = [0, 1, 2, 3]; print(list[2]) output?
Which of the following is a correct way to create a nested list?
In Python, which of the following will raise an IndexError?
What does the following code return? list = ['x', 'y', 'z']; print(list[-1])
Which of these operations can be performed on a list?
What will the following code output? list = [1, 2, 3]; list.append(4); print(list)
What does the expression 'len(list)' return?
Given the list 'nested = [[1, 2], [3, 4]]', how would you access the number '4'?
If you have a list 'alpha = [5, 10, 15]' and execute 'alpha[1:3]', what will be the output?
What happens when you execute 'list = [1, 2, 3]; list[0] = 10'?
Which of the following correctly removes an element from a list?
What does the statement 'list2 = list1' do in Python?
Which method is used to make a distinct copy of a list using slicing?
What will be the output of 'list1 = [1,2,3]; list2 = list(list1); list2.append(4); print(list1)'?
What is the purpose of the 'copy()' function from the copy module?
Which of the following will directly modify the original list when passed to a function?
Which of the following statements is FALSE about list copying in Python?
What happens if you modify an element in a shallow copy of a list?
If you want to copy a list that contains nested lists, which method will ensure the deep copy?
What is the effect of modifying a list inside a function where the list was passed as an argument?
Which of the following methods would you use to assign a copy of a list that maintains the changes separately?
Which of the following indicates that two lists are the same object in memory?
What is the simplest way to copy a list if it should include only elements, not nested lists?
What Python statement would create a copy of 'data' such that changes to 'copy_data' do not affect 'data'?
What will be the result of the operation list1 + list2 if list1 = [1, 2, 3] and list2 = [4, 5]?
Which method would you use to add an element at the end of a list?
What is the output of the following code: myList = [10, 20, 30]; myList[1] = 40; print(myList)?
How do you access the last element of a list called myList?
What will happen if you try to access a position in a list that is out of range?
Which of the following methods removes an element by its value from a list?
If myList = [5, 10, 15, 20] and you execute myList.pop(), what will be the output?
What is the time complexity of appending an item to a list in Python?
What will be the output of sorted([3, 1, 2])?
What does the extend() method do in regard to lists?
If you execute myList.clear(), what will myList become?
How do you sort a list named myList in descending order in Python?
Which of the following creates a nested list?
What will happen if you use myList.remove(25) when myList = [10, 20, 30]?
What is the primary difference between the pop() and remove() methods of a list?
How can you copy a list named myList to another list named newList?
What is a nested list?
How do you access the second element of a nested list within a list?
In the list example list1 = [1,2,'a','c',[6,7,8],4,9], what will list1[4][1] return?
Which of the following correctly describes how to traverse a nested list?
What will the output be for the command list1 = [[1, 2], [3, 4]] and then executing list1[0][1]?
Which method can be used to access each item in a list?
If a list is created as lst = [1, [2, 3], 4], what would lst[1][0] return?
What will be the output of the code: 'for i in range(len(list1)):' where list1 = [10, 20, 30]?
During list manipulation, what happens when you attempt to access an index that is out of range?
What will the index out of range error in Python indicate when accessing a list?
How can you create a copy of a nested list without affecting the original?
How would you print each item in 'list1' using a while loop?
What type of data structure is returned when accessing a single element of a nested list?
What is the first element of the list 'list1 = [3, 5, 7, 9]'?
Given the nested list lst = [1, [2, [3, 4], 5], 6], what is lst[1][1][0]?
When traversing a list, what does the 'len()' function return?
Which of the following is a correct way to check the length of a nested list?
Which of the following is NOT a valid way to traverse a list?
If a nested list is defined as nested = [[1, 2], [3, 4]], what will nested[0][0] return?
What will happen if you attempt to access list1[5] when list1 = [1, 2, 3]?
What is the main reason to use nested lists in programming?
Using which statement can you combine the functionalities of both 'for' and 'while' loops in a single traversal?
In a list traversal using 'for item in list1:', what will you access?
What is the correct way to initialize an empty list in Python?
If 'list1 = [1, 2, 3, 4]' and you want to print the last element, which index will you use?
In Python, how can you iterate with indices through a list of varying lengths?
What type of error occurs if you try to use list methods on a variable that is not a list?
When modifying a list during traversal, which method is generally safest to avoid skipping elements?
If you want to traverse a nested list, which method is correct?
What will be the output of the function call 'print_list([1, 2, 3])' if defined correctly to print all elements?
Which of the following statements correctly defines a function that accepts a list as an argument?
How do you pass a list to a function in Python?
What happens if you attempt to access an out-of-range index in a list passed to a function?
Which of the following is a valid way to modify a list inside a function?
When passing a list to a function, what is passed by default?
What will happen if you change an element of the list within a function?
What is the term for passing a copy of a list to a function?
Given the function 'def print_elements(lst):', what will 'print_elements([])' output?
What is the output of the following code? def modify_list(lst): lst[0] = 99; modify_list([1, 2, 3]) print([1, 2, 3])
How can you return multiple values from a function that takes a list?
Why is it essential to handle list boundaries when defining functions?
In which scenario would passing a list to a function result in unintended changes?
What does the `len()` function return when applied to a list?
What will `list1.append([5, 6])` do to the list `list1 = [1, 2, 3]`?
Which method will you use to combine elements from another list into an existing list?
What does the `remove()` method do when an element is not found in the list?
How does the `insert(index, element)` method work?
If `list1 = [1, 2, 3]`, what will `list1.pop(1)` return?
How can you find the index of the first occurrence of an element in a list?
What would be the result of executing `list1.count(5)` on `list1 = [1, 2, 3]`?
Which method should be used to clear all elements from a list?
What will the list be after `list1 = [1, 2, 3]; list1.append(4); list1.append(5)`?
What does `list1.pop()` do if `list1 = [10, 20, 30]`?
If `list2 = list1.copy()`, what does `list2` contain?
Regarding list methods, what is a key difference between `append()` and `extend()`?
What will happen if you call `list1.index(4)` on `list1 = [1, 2, 3]`?
Which method may cause an error if an element is not found when invoked?
What will the output be after executing the following code? list1 = [5, 3, 8, 6]; list1.sort(); print(list1)
What does the len() function return when applied to the list myList = [10, 20, 30]?
If myList = [1, 2, 3, 4] and the statement myList.append(5) is executed, what will myList contain?
What will be the output of list1 = [1, 2, 3]; list1.extend([4, 5]); print(list1)?
Which operator can be used to concatenate two lists in Python?
What does myList.pop(0) do when myList = [1, 2, 3]?
If list1 = [10, 20, 30, 40] and you execute list1.insert(2, 25), what will list1 be?
What would be the result of applying myList.remove(20) to myList = [10, 20, 30]?
What is the result of list1 = [1, 2, 3]; sorted(list1)?
After executing list1 = [1, 2, 3]; list1.reverse(); what will list1 contain?
If myList = [10, 20, 30, 40] and you execute myList.extend(myList), what will myList contain?
What is the output of list1 = ['a', 'b', 'c', 'd']; print(list1[1:3])?
Which statement is true regarding a nested list?
If list1 = [1, 2, 3] and you perform the operation list1 *= 2, what will the result be?
Download and practice Lists worksheets to improve problem-solving accuracy and speed for CBSE Class 11 Computer Science exams.
This worksheet covers essential long-answer questions to help you build confidence in Lists from Computer Science for Class 11 (Computer Science).
Questions
Define a list in Python and explain its key features. How does it differ from a string?
A list in Python is an ordered collection of elements that can contain mixed data types, including numbers, strings, and other lists. Lists are mutable, meaning their content can be changed after creation. Strings, on the other hand, are immutable sequences of characters that cannot be altered. To demonstrate, a list can look like: my_list = [1, 'Hello', 3.5, [2, 4]] while a string could be str = 'Hello'. Thus, elements in a list can be accessed and modified, while a string cannot be directly changed. Example includes the syntax for creating lists and strings.
Discuss the concept of indexing in lists. Provide examples of both positive and negative indexing.
Indexing in lists allows you to access individual elements using their position within the list. Python uses zero-based indexing, meaning the first element is accessed with index 0. Negative indexing allows access from the end, where -1 refers to the last element. For example, for list1 = [10, 20, 30, 40]: list1[0] returns 10, and list1[-1] returns 40. This enables flexible access irrespective of the list size.
Explain how to modify an existing list. Provide an example of using methods like append(), insert(), and remove().
You can modify an existing list in Python using methods such as append(), insert(), and remove(). To append an element, use list.append(element), e.g., list1.append(50) adds 50 to the end of list1. To insert an element at a specified position, use list.insert(index, element), such as list1.insert(2, 25) to add 25 at index 2. The remove() method deletes the first occurrence of a specified value, e.g., list1.remove(30) removes the first 30 found in list1.
What are list comprehensions in Python? Provide an example to demonstrate their usefulness.
List comprehensions in Python provide a concise way to create lists by iterating over an iterable and optionally applying a condition. For example, nums = [1, 2, 3, 4, 5] can be transformed into squares using: squares = [x**2 for x in nums]. This creates a new list, squares, containing the squares of each number in nums. This method is not only succinct but also enhances code readability.
Explain the concept of nested lists. How would you access and manipulate elements in a nested list?
A nested list is a list that contains other lists as its elements. You can access elements in a nested list using multiple indices. For example, my_list = [[1, 2], [3, 4]]; my_list[0][1] accesses the second element from the first list, which is 2. To manipulate, you can assign new values, for instance, my_list[1][0] = 5 changes the first element of the second list to 5, transforming my_list to [[1, 2], [5, 4]].
Discuss the operations of list concatenation and repetition in Python. Provide examples for each.
List concatenation combines two or more lists using the + operator, e.g., list1 = [1, 2] + list2 = [3, 4] results in [1, 2, 3, 4]. Repetition uses the * operator to repeat a list a specified number of times, for example, list1 = [1, 2] * 3 creates [1, 2, 1, 2, 1, 2]. Both operations allow for the creation of new lists without altering the original lists.
What is list slicing? Provide examples of how to slice a list in different ways.
List slicing allows you to obtain a subset of a list by defining a start and stop index. For example, given a list nums = [1, 2, 3, 4, 5], nums[1:4] returns [2, 3, 4] (inclusive of the start and exclusive of the end). You can also specify a step, e.g., nums[::2] provides [1, 3, 5]. If indices are omitted, it defaults to full range, e.g., nums[:] gives the entire list.
How can you pass a list to a function? Provide examples of both modifying and copying the list.
To pass a list to a function, simply include it as an argument. You can modify the list directly within the function, e.g., def modify(lst): lst.append(6) would add 6 to the caller's list. Alternatively, if you want to copy it without altering the original, use lst_copy = lst[:] or lst_copy = list(lst) for a shallow copy. This prevents changing the original while allowing manipulation of the copy.
Illustrate the built-in functions available for lists. Give examples for len(), max(), and sort().
Python provides several built-in functions for list operations: len() returns the number of elements, e.g., len(my_list) returns 5; max() returns the maximum element, e.g., max([1, 2, 3]) returns 3. The sort() method sorts a list in ascending order, e.g., my_list.sort() modifies the list directly. These functions streamline list manipulation and data extraction.
This worksheet challenges you with deeper, multi-concept long-answer questions from Lists to prepare for higher-weightage questions in Class 11.
Questions
Describe the various data types that can be included in a Python list. Provide examples for each type and explain how list indices work.
A Python list can contain data types such as integers (e.g., 1, 2, 3), floats (e.g., 1.0, 2.5), strings (e.g., 'hello', 'world'), tuples (e.g., (1, 2)), and even other lists (nested lists). For example: myList = [1, 'text', 3.14, (1, 2), [3, 4]]. List indices start from 0, so myList[0] returns 1, myList[1] returns 'text', and myList[-1] returns [3, 4].
Compare and contrast the manner in which the append() and extend() methods manipulate lists in Python. Provide code examples for better understanding.
The append() method adds its argument as a single element to the end of a list, while the extend() method iterates over its argument, adding each element to the list. For example: myList = [1, 2]; myList.append([3, 4]) results in [1, 2, [3, 4]], and myList.extend([3, 4]) results in [1, 2, 3, 4].
Explain the concept of list slicing in Python and provide examples that illustrate its functionalities, including positive, negative indices and step sizes.
List slicing creates a sub-list from a list and is done using the syntax list[start:stop:step]. Positive indices count from the start, while negative indices count backward. For example, with list = [0, 1, 2, 3, 4]: list[1:4] returns [1, 2, 3], list[-3:] returns [2, 3, 4], and list[::2] returns [0, 2, 4].
Discuss the differences between shallow copying and deep copying of lists in Python. Illustrate with code examples.
Shallow copying creates a new list with references to the objects in the original list. Deep copying creates a new list and recursively adds copies of nested lists. For example: import copy; a = [1, 2, [3, 4]]; b = copy.copy(a) (shallow) changes to b[2][0] affect a, while c = copy.deepcopy(a) does not.
How do list methods like sort() and sorted() differ? Provide examples that illustrate these differences.
sort() sorts the list in-place and returns None, while sorted() returns a new sorted list without altering the original. For example: a = [3, 1, 2]; a.sort() modifies a to [1, 2, 3], whereas b = sorted(a) returns [1, 2, 3] but a remains unchanged.
Explain how list elements can be accessed or traversed using loops. Provide an example of a for loop and a while loop to achieve this.
List elements can be accessed through iteration. Using a for loop: for i in myList: print(i) iterates through each element. With a while loop: i = 0; while i < len(myList): print(myList[i]); i += 1 iterates until the end, accessing elements via indexing.
Write a function that takes a list as an argument and returns the maximum, minimum, and the average of the list elements. Illustrate with an example.
def statistics(myList): return max(myList), min(myList), sum(myList)/len(myList). Example: For myList = [10, 20, 30], the function returns (30, 10, 20).
Show how list comprehension can be used to create a new list that consists of only the even numbers from an existing list.
Using list comprehension, we can write: evens = [x for x in originalList if x % 2 == 0]. This iterates through originalList and adds each element x to evens if it's even. For originalList = [1, 2, 3, 4], evens becomes [2, 4].
Design a small program that uses a menu to allow users to perform different list operations (e.g., append, insert, delete, display). Provide code snippets.
Use a while loop to display the menu, take input for choices, and perform list operations based on user input. Sample code: while True: print('Menu'); choice = input('Choose an option: '); execute_choice(choice).
Describe how a nested list can be manipulated in Python. Provide code examples demonstrating add, access, and modify.
A nested list can be accessed using two indices, e.g., list[x][y]. To add: list.append([newList]) appends a new nested list. To modify: list[i][j] = newValue changes the value at that position. Example: Given a = [[1, 2], [3, 4]]; a[1][0] = 5 changes the first element in the second list to 5.
The final worksheet presents challenging long-answer questions that test your depth of understanding and exam-readiness for Lists in Class 11.
Questions
Evaluate the implications of list mutability in real-world applications, particularly focusing on data manipulation in a financial software tool.
Discuss the effects of modifying lists on data integrity. Consider scenarios with concurrent access and how it might impact data reliability.
Analyze the differences between concatenating lists and using the extend method. In which scenarios might each be preferred?
Examine the efficiency and the memory implications of both methods, supported by examples. Discuss any scenarios where one may lead to errors.
Critique the list slicing technique in the context of large data sets. How can it be optimized or why might it be inefficient?
Analyze the computational time complexity and memory usage of slicing. Discuss potential alternatives when handling large data efficiently.
Explore how nesting lists can be employed to represent complex data structures. Use a practical example to illustrate this.
Provide an example of a nested list for a data-driven application, showing how it maintains relationships between elements.
Evaluate the impact of using a shallow copy versus a deep copy of lists in terms of data integrity and reliability in applications.
Discuss scenarios where mutable sub-elements may lead to unintended side effects and why understanding the difference is crucial.
Discuss real-life situations where the list methods like append, insert, or remove would present either advantages or constraints.
Consider situational use cases, for instance, in task management apps or inventory systems, focusing on practical data operations.
Analyze the implications of passing lists to functions, focusing on how references affect list manipulation and application design.
Discuss how Python’s reference mechanism can lead to unintended consequences if not managed carefully, with examples.
Compare the outcomes of list operations using built-in functions versus manual implementations. Where does one perform better than the other?
Critique both approaches, discussing efficiency and ease of maintainability backed up with examples and possible performance benchmarks.
Evaluate how the dynamic size of lists can affect performance in certain applications, compared to arrays or other data structures.
Discuss scenarios involving insertion and deletion operations in lists. Provide examples where lists excel or underperform.
Assess various methods for searching lists, including linear search versus other algorithms. Which would you recommend in different contexts?
Discuss the advantages and limitations of each searching technique, providing examples of list types or applications.
Delve into the chapter on Lists from Class 11 Computer Science, covering key concepts, operations, and practical examples for effective understanding.
Download worksheets, revision guides, formula sheets, and the official textbook PDF for Lists.
Lists Official Textbook PDF
Download the official NCERT/CBSE textbook PDF for Class 11 Computer Science.
Lists Revision Guide
Use this one-page guide to revise the most important ideas from Lists.
Lists Practice Worksheet
Solve basic and application-based questions from Lists.
Lists Mastery Worksheet
Work through mixed Lists questions to improve accuracy and speed.
Lists Challenge Worksheet
Try harder Lists questions that test deeper understanding.
Lists Question Bank
Download important questions and exam-style prompts from Lists.
Revise key terms and definitions from Lists with interactive flashcards. Quick recall practice for CBSE Class 11 Computer Science.
Practice Lists with Interactive Duels
Master Lists via Live Academic Duels
Challenge your classmates or test your individual retention on the core concepts of CBSE Class 11 Computer Science (Computer Science). Compete in speed-recall question rounds matched explicitly to the latest syllabus milestones for Lists.
Quick, competitive practice on Lists with zero setup.