Help
Contact
For teachers and institutes
Search courses, problems, tests…
A
A
>_
StemPy Lab
Courses ▾
Problems ▾
Practice ▾
Mock Tests
Classes
Community ▾
A
A
Quizzes
/
A program writes to a file inside a with block, then uses the file object after the block. What happens when the program runs?
Python Programming
Medium
High School (11–12)
Python Going Further › Files and Data Formats
Class 12 Board
PCAP (Python Institute)
+1 more exams
A-Level
A-Level
PCAP (Python Institute)
Created by
StemPy Lab
Stuck? Show a hint
A program writes to a file inside a
with
block, then uses the file object after the block.
with open("a.txt", "w") as f: print(f.closed, end=" ") f.write("hi") print(f.closed, f.name) f.write("again")
What happens when the program runs?
It prints
False True a.txt
and ends with no error
It prints
False True a.txt
, then stops with
ValueError
It prints
False False a.txt
, then stops with
ValueError
It prints
False True a.txt
, then stops with
OSError
Check Answer
Log in to save
Tag someone
⚑ Report
← All Quizzes
← A list comprehension with two for parts builds a small deck of card objects. What does the program print?
An iterator is made from a string. One value is taken with next, and a list comprehension uses the rest. What does the program print? →
More on
Python Going Further › Files and Data Formats
Discussion (0)
Log in
to join the discussion.
Loading…
All questions on this topic →
Problems on this topic
A to-do list is kept in a JSON file as a list of texts…
Medium
Write load_list(name) that gives the list that is saved in a JSON file…
Medium
For data = {"p": (1, 2), 3: "x", "t": {"a"}}, say what json.dumps(data) does, and what you must…
Medium
Write a CSV file scores.csv with the header name,score and the rows Asha,72 and Rao, Ravi,85 (the…
Easy
All problems on this topic →