w3resource logo


Python Exercises

Python File I/O: Assess if a file is closed or not

Python File I/O: Exercise-16 with Solution

Write a Python program to assess if a file is closed or not.

Sample Solution :-

Python Code :

 f = open('abc.txt','r')
print(f.closed)
f.close()
print(f.closed)

Output :

False
True

Python Code Editor:

 f = open('abc.txt','r')
print(f.closed)
f.close()
print(f.closed)

Improve this sample solution and post your code through Disqus



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number