Important Questions
Important Questions
1. Name the operations that can be performed on a list and outline any four with an
example.
Ans :
Lists
· List is an ordered sequence of items. Values in the list are called elements / items.
· It can be written as a list of comma-separated items (values) between square brackets[ ].
· Items in the lists can be of different data types.
Operations on list:
1. Indexing
2. Slicing
3. Concatenation
4. Repetitions
5. Updating
6. Membership
7. Comparison
List slices:
List slicing is an operation that extracts a subset of elements from an list and packages them
as another list.
Syntax:
Listname[start:stop]
Listname[start:stop:steps]
v default start value is 0
v default stop value is n-1
v [:] this will print the entire list
v [2:2] this will create a empty slice
List methods:
Methods used in lists are used to manipulate the data quickly.
These methods work only on lists.
They do not work on the other sequence types that are not mutable, that is, the values they
contain cannot be changed, added, or deleted.
syntax:
list name.method name( element/index/list)
2. Write a python program for linear search and binary search and explain its
implementation in detail.
3. Give a brief notes on python exception handling using try, except, raise and finally
statement.
4. Explain in detail python files ,their types, functions and operations that can be
performed on files with examples.
7 Marks :
6. Outline while loop, break statement and continue statement in python with an
example
8. Write separate python programs to illustrate create, access, concatenate and delete
operations in a tuple