1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
Fill in the blank. | ____ open("whatever.txt", "w") as file_to_work_with: | with | ^ *with *$ |
When you open a file by writing with at the beginning of the line, Python _______ the file automatically after you write to it. | closes | ^ *closes *$ | |
Fill in the blank. | _____________("whatever.txt", "w") as file_to_work_with: | with open | with `open |
The name of the file is "names.txt". Fill in the blank. | ____________________________, "w") as f: | with open("names.txt" | with open("names.txt" |
What is the file handle here? | with open("cities.txt", "w") as data: | data | ^ *data *$ |
Open the file "x.txt" so you can write to it. Make up the file handle. | with open("x.txt", "w") as the_file_to_write_to: | ^ *with open\(•x.txt•, •w•\) as [a-zA-Z_][a-zA-Z0-9_]*: *$ | |
Open a file so you can write to it. Make up the file name and file handle. | with open("recipes.txt", "w") as f: | ^ *with open\(•[-\w^&'@{}[\],$=!#().%+~ ]+\.txt•, •w•\) as [a-zA-Z_][a-zA-Z0-9_]*: *$ | |
If the Python program that opens a file is in the folder named python, the text file is in the folder named _______, according to this code. | with open("recipes.txt", "w") as f: | python | ^ *python *$ |
Open a text file that's in a different folder than the Python program that's opening it. Assume you're in Windows. Make everything up. | with open("text_files\recipes.txt", "w") as f: | ^ *with open\(•.+\\.+\.txt•, •w•\) as [a-zA-Z_][a-zA-Z0-9_]*: *$ | |
Open a text file that's in a different folder than the Python program that's opening it. Assume you're in OS X or Linux. Make everything up. | with open("text_files/recipes.txt", "w") as f: | ^ *with open\(•.+\/.+\.txt•, •w•\) as [a-zA-Z_][a-zA-Z0-9_]*: *$ | |
|
|||