NEW
Font size
WorksheetsPython Basics
Total questions: 10
Worksheet time: 5mins
Which of the following code snippets is the correct one for opening the hello.txt file for writing?
output_file = open("hello.txt", "r")
output_file = openFile("hello.txt", "w")
output_file = open("hello.txt", "w")
output_file = File("hello.txt", "w")
which mode is used to open a file for exclusive creation?
r
w
x
a
When you open a file using a with statement, Python will ________ the file automatically after you access it.
close
reset
delete
archive
Which operator can be used on a pathlib.Path object to extend the path it represents with subdirectories or filenames?
\
/
|
*
What does strip() do?
removes the content of the file
add in meta data
splits the file
Removes extra data at the beginning / end of the string
var = = {"apple", "banana", "cherry"}, represents:
sets
dictionary
tuple
list
df.shape is used to index, Datatype and Memory information
True
False
Which one is NOT a legal variable name?
my_Var
myvar
my#var
_myvar
Tuples are mutable.
True
false
Before data can be written to or read from a file in Python, the file must be ________ first.
append
open
close
replace
