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

Verified Command
             blessing[:6]
             blessing[2:10:4]
             blessing[3:10]
             blessing[-1::-1]
             blessing[-3:-12:-2]
        Program 32

        Consider the following strings:

             code1 = 'Stay Safe'
             code2 = 'stay alert and stay safe'
             code3 = 'STAY AWARE'

             code4 = '999999999'
             code5 = 'Call@999'
             code6 = 'Call999'
             code7 = '  '
             code8 = '  Be ethical   '
             code9 = 'safetyfirst'
        For each of the commands given in the second column of the table given below, write the output in the third column
        that will be produced on the execution of the statements (in the second column) by Python interpreter.

             Sr. No.                        Command                                       Output

                1    code1.count('a')                                         2
                2    code2.count('stay')                                      2
                3    code3.count('a')                                         0
                4    code1.lower()                                            'stay safe'
                5    code3.lower()                                            'stay aware'
                6    code2.upper()                                            'STAY ALERT AND STAY SAFE'
                7    code2.title()                                            'Stay Alert And Stay Safe'

                8    code2.capitalize()                                       'Stay alert and stay safe'
                9    code8.strip()                                            'Be ethical'
               10    code8.lstrip()                                           'Be ethical'
               11    code8.rstrip()                                           'Be ethical'
               12    code1.isupper()                                          False
               13    code3.isupper()                                          True

               14    code1.islower()                                          False
               15    code2.islower()                                          True
               16    code1.isalpha()                                          False
               17    code9.isalpha()                                          True
               18    code4.isdigit()                                          True
               19    code5.isdigit()                                          False




         442   Touchpad Computer Science-XI
   439   440   441   442   443   444   445   446   447   448   449