Merged branches
authorNishanth <nishanth@fossee.in>
Wed, 06 Oct 2010 15:40:46 +0530
changeset 220 01bb60f51398
parent 219 901b78003917 (diff)
parent 218 620a644c0581 (current diff)
child 221 7cd975ff5f0d
Merged branches
accessing-pieces-arrays.rst
advanced-features-functions.rst
getting-started-files.rst
getting-started-ipython.rst
loading-data-from-files.rst
loops.rst
manipulating-strings.rst
using-sage.rst
--- a/parsing_data.rst	Wed Oct 06 15:16:54 2010 +0530
+++ b/parsing_data.rst	Wed Oct 06 15:40:46 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
+
+