Page 281 - Computer Science Class 11 Without Functions
P. 281

elif x.isupper():
                          print("upper")
                      else:
                          print("all the best")

             Ans:  alphabet
                  alphabet
                  alphabet
                  all the best
                  digit
              14.  What will be the output produced on the execution of the following Python code?
                  Str = "Now ONLy OFFline"
                  for x in Str[2:-9]:
                      print("SCHOOL")

             Ans:  SCHOOL
                  SCHOOL
                  SCHOOL
                  SCHOOL
                  SCHOOL
              15.  What will be the output produced on the execution of the following Python code?
                  str = "#Den4"
                  for ch in str:
                      if(ch.isdigit()):
                          str = str[0:3]+'a'
                      elif 'e' in str:
                          str = str[0]+'zz'
                      elif 'P' not in str:
                          str = '9'+str[1:]+'z'
                      else:
                          str = str+'*'
                  print(str)

             Ans:  9zza


                   Assertion and Reasoning Based Questions


               The following questions are assertion(A) and reasoning(R) based. Mark the correct choice as
               a.  Both A and R are true and R is the correct explanation of A
               b.  Both A and R are true and R is not the correct explanation of A
               c.  A is true but R is false
               d.  A is false but R is true
               1.  Assertion(A):  A string in Python must be enclosed in double quotes, for example,"hello world"
                  Reasoning (R):  A string cannot be concatenated with a number.
               2.  Assertion(A):  Strings are immutable.
                  Reasoning(R):  Once a string object is created, it cannot be changed.
             Ans.  1. b  2. a


                                                                                                       Strings   279
   276   277   278   279   280   281   282   283   284   285   286