Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44d1406

Browse files
author
Amogh Singhal
authored
Update Python_Programming_Quiz.md
1 parent b9eb200 commit 44d1406

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎Python_Programming_Quiz.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,10 @@ __First:__ This assigns 3, 4, and 5 to a, b, and c respectively <br>
238238
` >>> a,b,c=3,4,5` <br>
239239
__Second:__ Ths assigns 3 to a, b, and c <br>
240240
`>>> a=b=c=3`<br>
241+
242+
#### 13. What is the `with` keyword in Python?
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+
- It may be used to open a file, do something, and then __automatically close the file at the end.__
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+
247+
`with` will __cleanup the resources even if an exception is thrown__

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /