Added questions to writing python scripts.
authorPuneeth Chaganti <punchagan@fossee.in>
Thu, 11 Nov 2010 10:37:26 +0530
changeset 465 78d20cd87c7e
parent 464 0bb297415dfb
child 468 ac1198488c0e
child 520 8249ae9d570a
Added questions to writing python scripts.
writing_python_scripts/questions.rst
--- a/writing_python_scripts/questions.rst	Thu Nov 11 09:58:20 2010 +0530
+++ b/writing_python_scripts/questions.rst	Thu Nov 11 10:37:26 2010 +0530
@@ -118,3 +118,29 @@
       Hello World
       Hello Test
 
+ 7. Say, we wish to use the ``pi`` value from the ``math`` module in
+    the standard library. How do we import it?
+
+    Answer: from math import pi  OR import math.pi OR 
+            import math.pi as pi
+
+            
+  8. A module should contain only functions, True or False?
+
+     Answer: False.
+  
+
+Larger Questions
+----------------
+
+1. Look at the python documentation (from the web) and learn how to
+   make a folder containing some python files into a module.
+
+   Answer: Add a file named __init__.py
+
+2. We know that ``sys.path`` has the paths in which Python checks for
+   a module, when it is imported. Suppose you have a package ``utils``
+   in some location on your disk, which is not on the python path, how
+   will you import it?
+
+   Answer: Append that path to the ``sys.path`` variable.