Search Header Logo

2.2 Reading and writing to a text file

Computers

10th Grade

Used 14+ times

2.2 Reading and writing to a text file
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When opening a text file was does 'r' do?

f=open("File.txt","r")

Opens text file to be read

Opens text file for appending text, adds data to end, creates new file if file doesn't exist.

Opens text file for writing text, creates new file and overwrites data if file exists.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the syntax - .read() do?

read the text file line by line and return all the lines as strings

reads all text from a file into a string or specific number of characters

read all the lines of the text file and return them as a list of strings

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the syntax - .readline() do?

read the text file line by line and return all the lines as strings

reads all text from a file into a string

read all the lines of the text file and return them as a list of strings

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the syntax - .readlines() do?

read the text file line by line and return all the lines as strings

reads all text from a file into a string

read all the lines of the text file and return them as a list of strings

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When opening a text file was does 'w' do?

f=open("File.txt","w")

Opens text file for reading text

Opens text file for appending text, adds data to end, creates new file if file doesn't exist.

Opens text file for writing text, creates new file and overwrites data if file exists.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When opening a text file was does 'a' do?

f=open("File.txt","a")

Opens text file for reading text

Opens text file for appending text, adds data to end, creates new file if file doesn't exist.

Opens text file for writing text, creates new file and overwrites data if file exists.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Identify the line of code to open a text file called space so that you can add data to the end of it.

file.close()

file.open("space.txt","w")

file.open("space.txt","a")

file.open("space","a")

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?