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

""" To use function alter()"""
                  myString = input("Enter a string:  ")
                  print("Original string: ", myString)
                  print("String after replacing alphabetic characters at even indices by corresponding
                  uppercase letters: ", alter(myString))
              13.  What will be the result of running the following Python code?
                 def mixUp(name):
                       for x in name:
                             if x.isalpha():
                                   print("alphabet")
                             elif x.isdigit():
                                   print("digit")
                             elif x.isupper():
                                   print("upper")
                             else:
                                   print("all the best")
                 mixUp("ToP#1")
             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:3]+'a'
                     elif 'P' not in Str:
                         Str = '9' + Str[1:] + 'z'
                     else:
                         Str = Str + '*'
                 print(Str)
             Ans.  9zza



                                                                                                       Strings   325
   322   323   324   325   326   327   328   329   330   331   332