Page 8 - IPP-12-2025
P. 8

28.  Ridhay is trying to create a dictionary and convert it into a dataframe using Pandas but his code contains
                     mistakes. Identify the errors, rewrite the correct code and underline the corrections made.   [2]
                     import pandas as pd
                     items = {'Fruits': ['Apple', 'Mango'], Quantity: [5, 7]} df =
                     pd.dataframe(items)
                     print(DF)
                                                               Or
                     Complete the given Python code to get the required output (ignore the dtype attribute) as:
                     import            as pd

                     months = ['Jan', 'Feb', 'Mar']
                     sales = [300, 400, 250]
                     sales_series = pd.               (sales, index=            )
                     print(          )
                Ans.  import pandas as pd
                     items = {'Fruits': ['Apple', 'Mango'], 'Quantity': [5, 7]}
                     df = pd.DataFrame(items)
                     print(df)
                                                               OR
                     import pandas as pd
                     months = ['Jan', 'Feb', 'Mar']

                     sales = [300, 400, 250]
                     sales_series = pd.Series(sales, index=months)
                     print(sales_series)
                                                    Section C (4 x 3 = 12 Marks)
                 29.  A tech company is disposing of old computer monitors irresponsibly.                     [3]
                     (a)  What environmental concerns are associated with this?
                     (b)  Suggest a responsible way of disposal.
                     (c)  How can this impact human health and biodiversity?
                Ans.  (a)  It can lead to release of lead and mercury into the environment.
                     (b)  Dispose through certified e-waste recyclers.
                     (c)  Toxic substances can cause neurological disorders in humans and disrupt animal habitats.

                 30.  Write a Python program to create the following dataframe using a dictionary of lists:   [3]

                      Item          Price          Stock
                      Pen           10             100
                      Pencil        5              200
                      Eraser        7              150
                      Sharpener     15             80
                                                               Or
                     Write a Python program to create a Pandas series, as shown below, using a dictionary. Note that the left
                     column indicates the indices and the right column displays the data.

                      Kiwi          50
                      Dragon Fruit   30
                      Blueberry     45



                                                                                    Model Test Paper         M.5
   3   4   5   6   7   8   9   10   11   12   13