Merged heads.
authorPuneeth Chaganti <punchagan@fossee.in>
Wed, 06 Oct 2010 18:57:25 +0530
changeset 226 c766a0b447f6
parent 225 94bcf44b05ad (current diff)
parent 222 d5249a528cae (diff)
child 227 54ff5ef55924
Merged heads.
--- a/lstsq.rst	Wed Oct 06 18:57:13 2010 +0530
+++ b/lstsq.rst	Wed Oct 06 18:57:25 2010 +0530
@@ -109,7 +109,6 @@
 This brings us to the end of the tutorial.
 we have learnt
 
- * how to use loadtxt to read files
  * how to generate a least square fit
 
 {{{ Show the "sponsored by FOSSEE" slide }}}
@@ -119,4 +118,22 @@
 
 Hope you have enjoyed and found it useful.
 Thank you
- 
+
+Questions
+=========
+
+ 1. What does ones_like([1, 2, 3]) produce
+
+   a. array([1, 1, 1])
+   #. [1, 1, 1]
+   #. [1.0, 1.0, 1.0]
+   #. Error
+   
+ 2. What does ones_like([1.2, 3, 4, 5]) produce
+
+   a. [1.2, 3, 4, 5]
+   #. array([1.0, 1.0, 1.0, 1.0])
+   #. array([1, 1, 1, 1])
+   #. array([1.2, 3, 4, 5])
+
+ 3. What is the shape of the 
--- a/parsing_data.rst	Wed Oct 06 18:57:13 2010 +0530
+++ b/parsing_data.rst	Wed Oct 06 18:57:25 2010 +0530
@@ -204,3 +204,84 @@
 Hope you have enjoyed and found it useful.
 Thank you
  
+Questions
+=========
+
+ 1. How do you split the string "Guido;Rossum;Python" to get the words
+
+   Answer: line.split(';')
+
+ 2. line.split() and line.split(' ') are same
+
+   a. True
+   #. False
+
+   Answer: False
+
+ 3. What is the output of the following code::
+
+      line = "Hello;;;World;;"
+      sub_strs = line.split()
+      print len(sub_strs)
+
+    Answer: 5
+
+ 4. What is the output of "      Hello    World    ".strip()
+
+   a. "Hello World"
+   #. "Hello     World"
+   #. "      Hello World"
+   #. "Hello World     "
+   
+   Answer: "Hello    World"
+
+ 5. What does "It is a cold night".strip("It") produce
+    Hint: Read the documentation of strip
+
+   a. "is a cold night"
+   #. " is a cold nigh" 
+   #. "It is a cold nigh"
+   #. "is a cold nigh"
+
+   Answer: " is a cold nigh"
+
+ 6. What does int("20") produce
+
+   a. "20"
+   #. 20.0
+   #. 20
+   #. Error
+
+   Answer: 20
+
+ 7. What does int("20.0") produce
+
+   a. 20
+   #. 20.0
+   #. Error
+   #. "20"
+
+   Answer: Error
+
+ 8. What is the value of float(3/2)
+
+   a. 1.0
+   #. 1.5
+   #. 1
+   #. Error
+
+   Answer: 1.0
+
+ 9. what doess float("3/2") produce
+
+   a. 1.0
+   #. 1.5
+   #. 1
+   #. Error
+
+   Answer: Error
+   
+ 10. See if there is a function available in pylab to calculate the mean
+     Hint: Use tab completion
+
+
--- a/tuples.rst	Wed Oct 06 18:57:13 2010 +0530
+++ b/tuples.rst	Wed Oct 06 18:57:25 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)
+
+