# HG changeset patch # User Nishanth # Date 1286359734 -19800 # Node ID 901b78003917c36954851564f05a3711fc9d741b # Parent 3cd0facc1eb957e22cb88f43e096541a89480053 added questions diff -r 3cd0facc1eb9 -r 901b78003917 parsing_data.rst --- a/parsing_data.rst Wed Oct 06 14:47:42 2010 +0530 +++ b/parsing_data.rst Wed Oct 06 15:38:54 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 + +