Search Header Logo

Python Files I/O

Authored by Karina Shrestha

Computers

6th - 12th Grade

Used 28+ times

Python Files I/O
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

8 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

1 min • 1 pt

Given the file rockets_nasa.txt, which of the following is the correct way to open the file for reading as a text file? Select all that apply.

open('rockets_nasa.txt')

open('rockets_nasa.txt', 'r')

open('rockets_nasa.txt', 'a')

open('rockets_nasa.txt', 'w')

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is not a method of opening files?

Replace

Append

Write

read

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the data type of data that is read in from a file?

real

integer

boolean

string

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Appending "flour" to your "grocery.txt" file will place the item at the start of the file.

True

False

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What does strip() do?

adds in random bytes of data

splits the file

removes spaces at the beginning and at the end of the string

removes spaces at the beginning and at the end of the file

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What does readlines() do?

reads all of the lines in the file and creates a list with one line of text in each item of the list

reads in one line from a file and doesn't create a list

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the last action that must be performed on a file? (after it has been opened for r/w/a mode)

save the file

close the file

rewrite the file

none of the above

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?