Page 454 - Computer Science Class 11 With Functions
P. 454

(forms part) of the first string. If yes, the function should display the starting index that marks the beginning of
             the second string; otherwise, it should display 'Substring DOES NOT exist'.
         14.   Write a program that accepts two strings and appends the shorter string after the longer one. For example, if
             string1 is 'Hi' and string2 is 'Hello', the output would be 'HelloHi'.
         15.   Write a function that accepts a list of n numbers as argument and returns the largest number. Do not use the built
             in methods, instead develop a function of your own to find the largest number in the list.
         16.   Write a program that accepts n strings and appends them to an empty list one by one to form a list of strings.
             Finally, traverse the list to display all strings that begin with a vowel.
         17.  Write a program that displays alternate elements of a list.

         18.   Write a function that accepts a list of n numbers and returns the number that appears the maximum number of
             times.

         19.   Write a program that accepts n numbers and stores them in a tuple. Thereafter, the program prints square of odd
             numbers and square root of even numbers.
         20.   Write a program that defines a tuple of n strings. Thereafter, a new tuple is created that has each element as
             (string, length of string). For example, given that

             tple = ('Rise', 'and', 'Shine', 'Always')
              the new tuple should be

             (('Rise',4),('and',3),('Shine',5),('Always',6))
         21.   Write a program that accepts the names and hobbies of 10 persons and stores this information in the form of a
             dictionary. The program should enumerate distinct hobbies.
         22.   Write a program in Python that accepts the names of the states and the number of districts in the states. The
             data is stored in a dictionary. Thereafter, the user is asked to enter a state and the number of districts in that state
             are displayed. Appropriate message is displayed if the name of the state does not exist in the dictionary. Create
             separate user defined functions to accept data and searching for states.









































         452   Touchpad Computer Science-XI
   449   450   451   452   453   454   455   456   457   458   459