SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
0.lists
Exercise:
Check Point
Question:4 | ISBN:978013274719 | Edition: 6

Question

Given lst = [30, 1, 2, 1, 0], what is the return value of each of the followingstatements?
lst.index(1)
lst.count(1)
len(lst)
max(lst)
min(lst)
sum(lst)

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

in list index()  method returns  the item of specified index.

so lst.index(1) returns the item 1.

count() method returns the number of times specified item occur in the list.

so lst.count(1)returns 2 number of times 1 occur on list.

len()  method retuns total length of the list.

so len(lst) returns 5.

max() method returns maximum number in the list.

so max(lst) returns 30.maximum number of the list.

min() method returns the minmum number in the list.

so min(lst) returns the 0.minimum number of the liist.

sum() method is used to sums up the numbers in list.

so sum(lst) returns 34.

 

0 0

Discussions

Post the discussion to improve the above solution.