Added questions
authorNishanth <nishanth@fossee.in>
Wed, 06 Oct 2010 16:33:53 +0530
changeset 222 d5249a528cae
parent 221 7cd975ff5f0d
child 226 c766a0b447f6
child 229 5c647a197103
Added questions
tuples.rst
--- a/tuples.rst	Wed Oct 06 16:15:42 2010 +0530
+++ b/tuples.rst	Wed Oct 06 16:33:53 2010 +0530
@@ -148,3 +148,59 @@
    Internal Reviewer 1 : 
    Internal Reviewer 2 : 
    External Reviewer   :
+
+Questions
+=========
+
+ 1. Define a tuple containing two values. The first being integer 4 and second
+    is a float 2.5
+
+   Answer: (4, 2.5)
+
+ 2. If ``a = (5, "Hello", 3.2)``. what is the value of a[2]
+
+   Answer: 3.2
+
+ 3. If ``a = 5,`` then what is the type of a
+
+   a. int
+   #. float
+   #. tuple
+   #. string
+
+   Answer: tuple
+
+ 4. if ``a = (2, 3)``. What does ``a[0], a[1] = (3, 4)`` produce
+
+   Answer: Error
+
+ 5. If ``a = ([2, 3], 4, 5)``. What is the value of ``a`` after doing
+    ``a[0].append(6)``
+
+    a. ([2, 3, 6], 4, 5)
+    #. Raises an error
+    #. ([2, 3], 4, 5)
+    #. [2, 3, 4, 5, 6]
+
+    Answer: ([2, 3, 6], 4, 5)
+
+ 6. What does the following code produce::
+
+      a = 5
+      b = "Hello"
+      a, b = b, a
+      print a
+      print b
+
+    Answer: Hello
+            5
+
+ 7. ``a = ("hello", "world", 5, 6, 8)``. What is the value of a[1:4]
+
+    Answer: ("world", 5, 6)
+
+ 8. ``a = (1, 2, 3, 4, 5, 6, 7, 8)``. What is the value of a[1::3]
+
+    Answer: (2, 5, 8)
+
+