Question 1 of 25
Hints left: 3
Q1
Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match='aaaa'>.
Q2
How can you write data to a file in Python?
Q3
What is the purpose of the write() method in file handling?
Q4
How can you close a file in Python?
Q5
How can you read the entire contents of a file line by line in Python?
Q6
To open a file c:\scores.txt for appending data, we use . . . . . . . .
Q7
What does the read() method of a file object do?
Q8
What is the purpose of the tell() method in file handling?
Q9
To open a file c:\scores.txt for reading, we use . . . . . . . .
Q10
What is the output of the following code: with open('data.txt', 'w') as file: file.write('Hello, world!')
Q11
How do you open a file named data.txt in read mode in Python?
Q12
What is the use of "a" in file handling?
Q13
How can you read a single line from a file in Python?
Q14
Which is/are the basic I/O connections in file?
Q15
To open a file c:\scores.txt for writing, we use . . . . . . . .
Q16
What will be the output of the following Python code? w = re.compile('[A-Za-z]+') w.findall('It will rain today')
Q17
What is the output of the following code: file = open('data.txt', 'r') content = file.read() print(content)
Q18
How can you create a new file in Python if it doesn't exist?
Q19
What is the output of the following code: with open('data.txt', 'a') as file: file.write('Appended line.') with open('data.txt', 'r') as file: content = file.read() print(content)
Q20
What is the purpose of the seek() method in file handling?
Q21
What will be the output of the following code: with open('data.txt', 'r') as file: lines = file.readlines() print(len(lines))
Q22
To read two characters from a file object infile, we use . . . . . . . .
Q23
What is the purpose of the with statement in file handling?
Q24
Which of the following statements are true?
Q25
Correct syntax of file.writelines() is?