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

while k<len(str1):
                    if str1[k]>="A" and str1[k]<="S":
                        str2=str2+str1[k+1]
                    elif str1[k]>="0" and str1[k]<="9":
                        str2=str2+str1[k-1]
                    else:
                        str2=str2+"*"
                    k=k+1
                print(str2)
           8.  Differentiate between find() and index() with respect to strings in Python.
           9.  Using built-in functions, write Python statements to do the following tasks on the string named "myString ".
              (i)  To remove the trailing spaces from the string.
              (ii)  To capitalize the first character of every word in a string.
              (iii)  To check whether all characters of a string are in uppercase.
              (iv)  To display the words of the strings as elements of a list.
              (v)  To check display the index from where the substring String starts.
              (vi)  To convert the lowercase alphabets of a string to uppercase.
              (vii) Reverses a string.
          10.  Write a program that accepts a string and a character and replaces each occurrence of the character with  '*'.
          11.  Write a program that takes a string as input and outputs the number of words in the string.
          12.  Write a program that counts the number of vowels in a string. (both uppercase and lowercase)
          13.  Write a program that reverses the characters of each word in a string.
          14.  Write a program that accepts a string and prints the following:
              a.  Number of words beginning with a vowel
              b.  Number of 3-lettered words
              c.  Number of digits
          15.  Write a program that accepts a string and prints a string, replacing each lowercase alphabet in the input string with
              uppercase and vice versa.
          16.  Extend the module stringFns.py  to perform the following operations on strings without using built-in functions:
              a.  Find the first occurrence of the substring subStr in the string s.
              b.  Find the last occurrence of the substring subStr in the string s.
              c.  Find the frequency of the substring subStr in the string s.
              d.  Find the number of consonants present in the given string s.
              e.  Find the number of uppercase and lowercase letters in the given string s.
              f.  Find the most frequently occurring character in the string s.
              g.  Reverse every word in the given sentence s.


                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



         284   Touchpad Computer Science-XI
   281   282   283   284   285   286   287   288   289   290   291