Page 94 - Informatics_Practices_Fliipbook_Class12
P. 94

17.  Consider the following statements:                                                          [2022]
              Statement A:  .loc() is a label based data selecting method to select a specific row(s) or column(s) which we want to
                          select.
              Statement B: .iloc( )can not be used with default indices if customized indices are provided.
              a.  Statement A is True but Statement B is False
              b.  Statement A is False but Statement B is True
              c.  Statement A and Statement B both are False
              d.  Statement A and Statement B both are True

         Ans.  a. Statement A is True but Statement B is False
          18.  Abhay is a student of class 'XII', and he is aware of some concepts of python. He has created the DataFrame, but he is
              getting errors after executing the code. Help him by identifying the correct statement that will create the DataFrame:
                                                                                                           [2022]
               Code:
              import pandas as pd
              stuname=[Muskan', 'Radhika', Gopar', 'Pihu']
              terml=[70, 63, 74, 90]
              term2=[67, 70, 86, 95]
              a.  df=pd.DataFrame({"Name":stuname,"marks1":term1,"marks2":term2})
              b.  df=pd.dataframe([stuname, term1,term2], columns=['stuName',"marks1", "marks2"])
              c.  df=pd.DataFrame({stuname, term1,term2})
              d.  df=PD.dataframe({stuname, term1,term2})
         Ans.  a. df=pd.DataFrame({"Name":stuname,"marks1":term1,"marks2":term2})

          19.  Mr. Raman created a DataFrame from a Numpy array:                                           [2022]
              arr=np.array([2, 4, 8], [3, 9, 27],[4, 16, 64])
              df=pd.DataFrame (arr, index=['one','two', three'], _______)
              print (df)
              Help him to add a customized column labels to the above DataFrame
              a.  columns='no', 'sq', 'cube'                  b. column=[no', 'sq', 'cube']
              c.  columns=['no', 'sq', 'cube']                d. columns=[['no', 'sq', 'cube']

         Ans.  c. columns=['no', 'sq', 'cube']
          20.  What will be the output of the following program?                                           [2022]
              import pandas as pd
              dic={'Name' : ['Sapna', 'Anmol', 'Rishul','Sameep'],
              'Agg':[56, 67,75, 76], 'Age': [16,18,16,19] }
              df=pd.DataFrame (dic, columns= [ 'Name', 'Age'])
              print (df)
             a.     Name        Agg        Age                 b.    Name          Agg          Age
               101  Sapna        56        16                      0  Sapna         56           16
               102  Anmol        67        18                      1  Anmol         67           18
               103  Rishul       75        16                      2  Rishul        75           16
               104  Sameep       76        19                      3  Sameep        76           19
             c.     Name                                       d.    Name          Age
               0  Sapna                                            0  Sapna         16
               1  Anmol                                            1  Anmol         18
               2  Rishul                                           2  Rishul        16
               3  Sameep                                           3  Sameep        19





          80   Touchpad Informatics Practices-XII
   89   90   91   92   93   94   95   96   97   98   99