equal
deleted
inserted
replaced
116 |
116 |
117 Answer:: |
117 Answer:: |
118 Hello World |
118 Hello World |
119 Hello Test |
119 Hello Test |
120 |
120 |
|
121 7. Say, we wish to use the ``pi`` value from the ``math`` module in |
|
122 the standard library. How do we import it? |
|
123 |
|
124 Answer: from math import pi OR import math.pi OR |
|
125 import math.pi as pi |
|
126 |
|
127 |
|
128 8. A module should contain only functions, True or False? |
|
129 |
|
130 Answer: False. |
|
131 |
|
132 |
|
133 Larger Questions |
|
134 ---------------- |
|
135 |
|
136 1. Look at the python documentation (from the web) and learn how to |
|
137 make a folder containing some python files into a module. |
|
138 |
|
139 Answer: Add a file named __init__.py |
|
140 |
|
141 2. We know that ``sys.path`` has the paths in which Python checks for |
|
142 a module, when it is imported. Suppose you have a package ``utils`` |
|
143 in some location on your disk, which is not on the python path, how |
|
144 will you import it? |
|
145 |
|
146 Answer: Append that path to the ``sys.path`` variable. |