Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 156 - 2620_Birla Open Mind C-8
P. 156

    6.   What is the purpose of using max(list) and min(list) functions? Give examples.

                                                                                                         21 st
                  E.     Brain Boost.                                                                 Century   #Critical Thinking
                                                                                                        Skills
                          1.  What will be the output of the following programs?

                             a.  list1=[13, 25, 41, 63, 82]

                               list1[1]=50

                               list1[3]=45
                               print(list1[:])
                             b.  list1=[13, 25, 41, 63, 82]

                               list1.append(19)

                               print(list1)

                             c.  list1=[13, 25, 41, 63, 82]

                               list1.insert(1, 302)

                               print(list1)

                             d.  list1=[13, 25, 41, 63, 82]

                               list2=[14, 26, 42, 64]
                               print(len(list1))

                               print(max(list2))

                               print(min(list1))
                             e.  list1=[13, 25, 41, 63, 82]

                               print(list1[4])
                          2.   Find errors in the code given below.
                             a.  new_list = ['a';'b';'c';'d';'e']

                               print(new_list[-1]):

                               print(new_list:[-5])

                             b. my_list = ['o','r','a','n','g','e'];

                               print(my_list[2;5])
                               print(my_list[5:]):

                               print(my_list[::])

                      154  Premium Edition-VIII

| 151 152 153 154 155 156 157 158 159 160 161 |