Page 43 - PYTHON-12
P. 43

Write the definition of the user-defined function ‘Push_vowels(word)’ that accepts a single word and pushes
                 each vowel in the word onto a Stack named VowelStack.
                  Write another function Pop_vowel() to pop the topmost vowel from VowelStack and return it. If the Stack is
                 empty, it should display ‘No vowels in stack’.
                  Write function Display_vowels() to display all vowels in VowelStack without removing them. If the Stack is
                 empty, the function should display ‘None’.
              31.  Predict the output of the following code.                                               (3)

                 data_rec = {'R1': (10, 22, 38), 'R2': (94, 15, 56)}
                 for key, value in data_rec.items():

                     if 22 in value:
                       data_rec[key] = value + (40,)
                 print("Modified dictionary:", data_rec)
                                                           OR
                  Predict the output of the following code.

                 values = [2, 4, 6, 8]

                 for x in range(len(values)):
                     values.insert(x , values.pop())
                 print("Reordered list is:", values)

                                                        Section D

              32.  Consider the table MOVIES and answer the following questions.                           (4)

             Movie_ID        Title            Genre        Director_Name      Box_Office      Year_Released
             1         Inception        Sci-Fi            Christopher Nolan 836,800,000     2010
             2         The Dark Knight  Action            Christopher Nolan 1,005,000,000   2008
             3         Avatar           Sci-Fi            James Cameron    2,847,000,000    2009

            Note: The table contains more records than shown here.
              (A)  Write the following queries:
                  (I)  To display the total Box_Office earnings for each Genre, excluding Genres with total earnings less than
                     10 million.
                 (II)  To display MOVIES table sorted by Box_Office in descending order.
                 (III)  To display the distinct director names from MOVIES table.
                 (IV)  To display the sum of Box_Office for all movies where Year_Released is NULL.

                                                           OR
              (B)  Write the output of the following:
                  (I)  SELECT  Director_Name, sum(Box_Office)  as total_earnings  FROM  MOVIES
                     GROUP BY Director_Name;
                 (II)  SELECT * FROM MOVIES WHERE Genre LIKE '%on%';
                 (III)  SELECT Movie_ID, Title, Genre, Box_Office FROM MOVIES WHERE Box_Office
                     BETWEEN 5000000 AND 20000000;
                 (IV)  SELECT MAX(Box_Office) FROM MOVIES;






            A.6    Computer Science–XII
   38   39   40   41   42   43   44   45   46   47   48