Python Text & Binary Files

Python Text & Binary Files

12th Grade

15 Qs

quiz-placeholder

Similar activities

Bài 1 Excel - thẻ Home

Bài 1 Excel - thẻ Home

12th Grade

20 Qs

emtech

emtech

12th Grade

10 Qs

1.2.4. Types of Programming Language

1.2.4. Types of Programming Language

12th Grade

12 Qs

Topic 4.1 Introduction to Java

Topic 4.1 Introduction to Java

12th Grade

20 Qs

SOFTWARE 7I

SOFTWARE 7I

7th Grade - University

20 Qs

Year 10 Data Transmission

Year 10 Data Transmission

9th - 12th Grade

13 Qs

Word 2016 Lesson 1

Word 2016 Lesson 1

9th - 12th Grade

10 Qs

POWERPOINT QUIZZ

POWERPOINT QUIZZ

10th - 12th Grade

20 Qs

Python Text & Binary Files

Python Text & Binary Files

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Anshu Sharma

Used 11+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

15 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Given a text file opened as file_in, which of the following will print the entire file? (Select ALL that apply.)

print(file_in.read())

print(file_in)

lines = file_in.readlines()

for line in lines:

print(line)

lines = file_in.readlines()

for i in range(len(lines)):

print(lines)

for line in file_in:

print(line)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to open the file file_in.txt for reading?

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

open('file_in.txt','r+')

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

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

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the best way to read an entire file into a list of strings?

.read()

.readline()

.readlines()

.read(all)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When reading text files, what are the hidden characters typically at the end of each line?

\n

#

@

»

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

If I want to add to the end of a text file, I should:

MyCipher = open("MyCipher.txt", "w")

MyCipher = open("MyCipher.txt", "a")

MyCipher = open("MyCipher.txt", "w+")

MyCipher = open("MyCipher.txt", "s")

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How do you close the file?

MyFile = close()

MyFile.close

close = MyFile()

MyFile.close()

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Why is it best to open a file with "with" in Python?

It automatically closes the file

Easier to read the code

Better for binary files

Closers to the pseudocode

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?