Page 101 - tp_Modula_v2.0
P. 101

3.   Which of the following does min( ) returns?

                          a.   Largest item in the tuple                b.   Number of items in the tuple
                          c.   Smallest item in the tuple               d.   None of these
                     4.   Which of the following statements is/are True?
                          a.   Tuples have structure, lists have an order

                          b.   Tuples are homogeneous, lists are heterogeneous
                          c.   Tuples are immutable, lists are mutable

                          d.   All of the above
                     5.   Which of the following statement is correct about len( ) function?
                          a.   Returns the total length of the tuple
                          b.   Returns the largest element of the tuple

                          c.   Returns the smallest element of the tuple
                          d.   Returns the sum of all the elements of the tuple

                 B.  Write 'T' for true and 'F' for false.
                       1.   Tuple contains any number of elements of heterogeneous type.                ……………………

                     2.   The index of a tuple starts from 0.                                           ……………………

                     3.   Slicing operator is used to get certain range of tuple elements.              ……………………
                     4.   count(a) returns the index of first element in tuple.                         ……………………

                 C.  Fill in the blanks using the words given below:


                                                   max( ), comma, slicing, positive, sorted( )



                     1.   To declare a Tuple with one item you need to specify …………………… after the item.
                     2.   The elements from left to right are traversed using the …………………… indexing.


                     3.   To sorted list of elements …………………… method is used.

                     4.   …………………… method returns the largest element of the tuple.

                     5.   …………………… is extracting the sub parts of the tuple.

                 D.   Short answer type questions.

                     1.   What is tuple?
                     2.   What is the use of count(a) method?
                     3.   How will you create tuple with zero and first element?
                 E.   Long answer type questions.

                     1.   How will you access tuple elements by index numbers? Explain with an example.
                     2.   What is the difference between lists and tuples?

                     3.   Define any four tuple functions.

                                                                                               Tuple in Python    99
   96   97   98   99   100   101   102   103   104   105   106