Python Files

Python Files

University

20 Qs

quiz-placeholder

Similar activities

POST-TEST TERMINOLOGI LINUX

POST-TEST TERMINOLOGI LINUX

University

20 Qs

Quiz_Adv

Quiz_Adv

University

20 Qs

Python Threads

Python Threads

University

16 Qs

Quiz Basis Data

Quiz Basis Data

University

15 Qs

CPA MS-Office Hotkeys Quiz

CPA MS-Office Hotkeys Quiz

8th Grade - Professional Development

21 Qs

Informatika Kelas 5 Bab 2

Informatika Kelas 5 Bab 2

5th Grade - University

19 Qs

Quiz on Misinformation and Bias

Quiz on Misinformation and Bias

10th Grade - University

18 Qs

Python Files

Python Files

Assessment

Quiz

Computers

University

Medium

Created by

Elaine Cortez

Used 325+ times

FREE Resource

AI

Enhance your content in a minute

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

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the following file opened as song_file:


I can't write one song that's not about you

Can't drink without thinkin' about you

Is it too late to tell you that

Everything means nothing if I can't have you?


What is the result of

print(song_file.read(4)) ?

I ca

I can

I c

I can't write one song that's not about you

Can't drink without thinkin' about you

Is it too late to tell you that

Everything means nothing if I can't have you?

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the following file opened as song_file:


I can't write one song that's not about you

Can't drink without thinkin' about you

Is it too late to tell you that

Everything means nothing if I can't have you?


What is the result of

print(text_file.readline(8)) ?

I can't

I can

I can't write one song that's not about you

Error

3.

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)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the following file opened as song_file:


I can't write one song that's not about you

Can't drink without thinkin' about you

Is it too late to tell you that

Everything means nothing if I can't have you?


What is the result of

print(text_file.readlines()[1]) ?

Can't drink without thinkin' about you

I can't write one song that's not about you

I can't write one song that's not about you

Can't drink without thinkin' about you

Is it too late to tell you that

Everything means nothing if I can't have you?

I

5.

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')

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the best way to read an entire file into a single string?

.read()

.readline()

.readlines()

.read(all)

7.

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)

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?