You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Python_Programming_Quiz.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -239,9 +239,14 @@ __First:__ This assigns 3, 4, and 5 to a, b, and c respectively <br>
239
239
__Second:__ Ths assigns 3 to a, b, and c <br>
240
240
`>>> a=b=c=3`<br>
241
241
242
-
#### 13. What is the `with` keyword in Python?
242
+
#### 14. What is the `with` keyword in Python?
243
243
The `with` statement in Python ensures that cleanup code is executed when working with unmanaged resources by encapsulating common preparation and cleanup tasks. <br>
244
244
- It may be used to open a file, do something, and then __automatically close the file at the end.__
245
245
- It may be used to open a database connection, do some processing, then __automatically close the connection to ensure resources are closed and available for others__.
246
246
247
247
`with` will __cleanup the resources even if an exception is thrown__
248
+
249
+
#### 15. What is the `PYTHONPATH` variable?
250
+
`PYTHONPATH` is the variable that tells the __interpreter where to locate the module files imported into a program__.<br>
251
+
Hence, it must include the Python source library directory and the directories containing Python source code. <br>
252
+
You can manually set PYTHONPATH, but usually, the Python installer will preset it.
0 commit comments