[Type C]Q1. Write a python program directed for the Linear Lists in the problem statement.

What are Linear Lists?

A list is a collection that is ordered and changeable. In Python, lists are written with square brackets.

Lists are just like dynamic sized arrays, declared in other languages. Lists do not need to be homogeneous always, which makes it a most powerful tool in Python.

A single list may contain DataTypes like Integers, Strings, as well as Objects.

Lists are mutable, and hence, they can be altered even after their creation.

List Operations: Some common functions of lists are

Append()Add an element to the end of the list
Extend()Add all elements of a list to the another list
Insert()Insert an item at the defined index
Remove()Removes an item from the list
Pop()Removes and returns an element at the given index
Clear()Removes all items from the list
Index()Returns the index of the first matched item
Count()Returns the count of number of items passed as an argument
Sort()Sort items in a list in ascending order
Table of most used functions of list.

Problem: Write a program that uses a function called find_in_list() to check for the position of the first occurrence of v in the list passed as parameter(1st) or -1 if not found. The header for the function is given below:

Program code:



In the above code snippet basic functions of list are demonstrated.

To view all the lessons in chapter 9: http://computertutor.in/class-12-computer-science/chapter-9/

To view entire class 12 computer science study material: http://computertutor.in/resources/

You cannot copy content of this page