[Type C]Q5. 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: Suppose we have a list V where each element represents the visit dates for a particular patient in the last month. We want to calculate the highest number of visits made by any patient. Write a function MVisist(Lst) to do this.

Program code:

Output:

Highest number of visits are : [1, 8, 15, 22, 29]

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