summaryrefslogtreecommitdiff
path: root/tuples.rst
diff options
context:
space:
mode:
authorNishanth Amuluru2010-10-06 16:33:53 +0530
committerNishanth Amuluru2010-10-06 16:33:53 +0530
commit783d71348c6449b561a5b5cdd17038cdee74dcca (patch)
treed6e95218d4708ca48e2de9dde48962dca5c1bd5f /tuples.rst
parent296bf99770ef42225d29318ca618ebe3a3439003 (diff)
downloadst-scripts-783d71348c6449b561a5b5cdd17038cdee74dcca.tar.gz
st-scripts-783d71348c6449b561a5b5cdd17038cdee74dcca.tar.bz2
st-scripts-783d71348c6449b561a5b5cdd17038cdee74dcca.zip
Added questions
Diffstat (limited to 'tuples.rst')
-rw-r--r--tuples.rst56
1 files changed, 56 insertions, 0 deletions
diff --git a/tuples.rst b/tuples.rst
index 1a6cf7f..e6c060c 100644
--- a/tuples.rst
+++ b/tuples.rst
@@ -148,3 +148,59 @@ Thankyou
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)
+
+