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

14.  Write a program that accepts a string and prints the following:
                  (i)  Number of words beginning with a vowel
                  (ii)  Number of 3-lettered words
                  (iii)  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:
                  (i)  Find the first occurrence of the substring subStr in the string s.
                  (ii)  Find the last occurrence of the substring subStr in the string s.
                  (iii)  Find the frequency of the substring subStr in the string s.
                  (iv)  Find the number of consonants present in the given string s.
                  (v)  Find the number of uppercase and lowercase letters in the given string s.
                  (vi)  Find the most frequently occurring character in the string s.
                  (vii)  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
               1.  Assertion(R):  Python allows a string literal to span multiple lines.
                  Reasoning(R):  A multiline string is enclosed between triple single quotes or triple double quotes.

               2.  Assertion(A):  First character in a string is at index 0, the next is at index 1, and so on.
                  Reasoning(R):  For any non-empty string s, s[len(s)-1] and s[-1] both return the last character.


                  Case Based Questions


               1.  Every  email  address  consists  of  three  parts  -  unique  id,  ‘@’,  and  domain  name.  For  example,  in  the  email-id
                  rknararayan@bbpspp.co.in, rknararayan is the unique id, and bbpspp.co.in is the domain name.
                  Write a Python program that accepts a list of email ids and counts the number of email ids having the domain gmail.com

               2.  Rashmi knows that a number can be converted to string using the function str() and a string can be converted into an
                  integer using int(). She wants to work with strings (comprising alphabets, digits, and special characters ) as user input.
                  She wants to see the number obtained on ignoring the non-digit characters. Once she gets the number, she wants to square
                  it up. Help Rashmi in writing a Python program that achieves this.




              Multiple Choice Questions
              1. (c)     2. (d)      3. (b)     4. (a)     5. (d)      6. (d)     7. (a)     8. (b)      9. (d)
              10. (c)    11. (b)     12. (a)    13. (c)    14. (b)     15. (a)    16. (d)    17. (b)     18. (a)
              True or False
              1. (F)     2. (F)      3. (T)     4. (F)     5. (T)      6. (F)     7. (F)
              Fill in the blanks
              1. str               2. backslash(\)       3. index              4. len()             5. str()
              6. slice             7. s                  8. title()



                                                                                                       Strings   331
   328   329   330   331   332   333   334   335   336   337   338