manipulating-strings/questions.rst
changeset 522 d33698326409
parent 521 88a01948450d
child 523 54bdda4aefa5
--- a/manipulating-strings/questions.rst	Wed Nov 17 23:24:57 2010 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-Objective Questions
--------------------
-
-.. A mininum of 8 questions here (along with answers)
-
-1. Given the list week::
-
-     ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]
-
-   ``"Sun" in week`` returns True or False?
-
-   Answer: False
-   
-#. Given the string ``s = "palindrome"``, what is returned by s[4:]
-
-   Answer: ``ndrome``
-
-#. Given the string ``s = "palindrome"``, what is returned by s[-4]
-
-   Answer: ``r``
-
-#. Given the string ``s = "palindrome"``, what is returned by s[4::-1]
-
-   Answer: ``nilap``
-
-#. Given the string ``s = "palindrome"``, what is returned by s[-4:]
-
-   Answer: ``rome``
-
-#. Given a string ``s = "this is a string"``, how will you change it
-   to ``"this isn't a list"`` ?
-
-   Answer::
-   
-     s = s.replace("string", "list")
-     s = s.replace("is", "isn't")
-
-#. Given a string ``s = "this is a string"``, how will you change it
-   to ``"THIS ISN'T A LIST"`` ?
-
-   Answer::
-   
-     s = s.replace("string", "list")
-     s = s.replace("is", "isn't")
-     s = s.upper()
-
-#. Given a line from a CSV file (comma separated values), convert it
-   to a space separated line. 
-
-   Answer: line.replace(',', ' ')
-
-#. Given the string "F.R.I.E.N.D.S" in s, obtain the "friends".
-
-   Answer: ``s[::2].lower()``
-
-Larger Questions
-----------------
-
-.. A minimum of 2 questions here (along with answers)
-
-1. Given the string friends, obtain the string "F.R.I.E.N.D.S". 
-
-   Answer::
-   
-     s = "friends"
-     s = s.upper()
-     s_list = list(s)
-     ".".join(s_list)
-
-2. Given a string with double quotes and single quotes. Interchange
-   all the double quotes to single quotes and vice-versa. [Solve it
-   for this particular string. Not a generic one. Solve it for a
-   generic string, if you know how to iterate over a list.]
-
-   s = """ "Isn't this a 'simple' task?" "No, it isn't." "Yes! it is." """
-
-   Answer::
-   
-     s = s.replace('"', '#')
-     s = s.replace("'", '"')
-     s = s.replace('#', "'")        
-
-   .. depends on ``for`` which is not an LO dependency a generic string. 
-   
-   For generic string
-   Answer:: 
-
-     S = []
-     s_list = s.split("'")
-
-     for s_s in s_list:
-         S.append(s_s.replace('"', "'"))
-
-     s = '"'.join(S)