Page 35 - PYTHON-12
P. 35

(a)  values = [10, 7, 5, 8, 3]

                   squarenumber_list = []
                   for num in values:
                       squarenumber_list.append(num ** 2)
                   print("List of Original numbers:", values)
                   print("List of Squared numbers:", squarenumber_list)
                   print("Sum of squared numbers:", sum(squarenumber_list))
                                                       Section D
            32.  Consider the given table GIFTS:                                                           (4)

                    Gift_ID     Gift_Name       Quantity       Marks
                G1901          Pen Stand     20            4000
                G1809          SUP Game      10            8000
                G1902          Soft Toys     5             5600
                G1790          Watch         15            9500
               Note: The table contains more records than shown here.
                (a)  Write the following queries:
                    (i)  To display the total quantity of each gift, excluding gifts with total quantity less than 10.
                    (ii)  To display GIFTS table sorted by total price in ascending order.
                   (iii)  To display the distinct gift names from GIFTS table.
                    (iv)  Display the average price of those gifts whose names contain the letter ‘t’.
                                                          OR
                (b)  Write the output:
                    (i)  Select Gift_Name, sum(Quantity) as 'total_quantity' from GIFTS group by
                       Gift_Name;
                    (ii)  Select * from GIFTS where Gift_Name like ‘S%’;
                   (iii)  Select Gift_ID, Gift_Name, Quantity, Price from GIFTS where price > 1000;
                    (iv)  Select min(Price) from GIFTS;
            33.  A csv file ‘Success.csv’ contains the data of a survey. Each record of the file contains the following data:  (4)
                 •  Name of the City
                 •  Number of people in City
                 •  Sample Size (Number of people who participated in the survey in that city)
                 •  Success (Number of people who accepted that they were Successful)
                For example, a sample record of the file may be:
               ['Delhi', 33807000, 5500, 2560]
                Write the following Python functions to perform the specified operations on this file:
                (i)  Read all the data from the file in the form of a list and display all those records for which the number of
                   people is more than 30000000.
                (ii)  Count the number of records in the file.

            34.  Rajesh works as a Database Administrator in an IT company. He needs to access some information from
               EMPLOYEES and PROJECTS tables for a survey analysis. Help him extract the following information by writing
               the desired SQL queries as mentioned below.                                                 (4)
                                                  Table: EMPLOYEES
                   EMP_ID       EMP_FIRSTNAME      EMP_LASTNAME       DATE_OF_JOINING      SALARY
                E4001          Alina              Gupta              2010-02-10         25000
                E4002          Sumit              Pathak             2012-06-09         28000
                E4003          Sakshi             Sharma             2003-05-16         12000
                E4004          Lavanya            Grover             2021-10-05         45000
                E4006          Tarun              Arora              2020-08-14         35000

          A.50                                                           Computer Science with Python–XII
   30   31   32   33   34   35   36   37   38   39   40