Understanding Files in Python

Understanding Files in Python

University

102 Qs

quiz-placeholder

Similar activities

bộ 2 cntt

bộ 2 cntt

University

103 Qs

ACC Semester Review 24-25

ACC Semester Review 24-25

6th Grade - University

100 Qs

College Prep/ Algebra 2

College Prep/ Algebra 2

University

104 Qs

Mechanical Engineering Quiz

Mechanical Engineering Quiz

University

103 Qs

Câu hỏi về Ngân hàng và Tài chính

Câu hỏi về Ngân hàng và Tài chính

University

101 Qs

Q. E 3

Q. E 3

12th Grade - University

106 Qs

api 510

api 510

University

100 Qs

Understanding Files in Python

Understanding Files in Python

Assessment

Quiz

Mathematics

University

Medium

Created by

Van Khanh

Used 1+ times

FREE Resource

102 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you open a file for reading in Python?

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

open('file.txt', 'write')

open('file.txt', 'append')

open('file.txt', 'create')

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which mode is used to open a file for writing, overwriting the file if it already exists?

'r'

'a'

'w'

'x'

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you close a file after opening it?

file.close()

file.end()

file.stop()

file.quit()

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What method is used to read the entire contents of a file?

file.read()

file.readall()

file.get()

file.readfile()

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method reads a single line from a file?

file.readline()

file.getline()

file.readline()

file.nextline()

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you write data to a file?

file.write(data)

file.append(data)

file.insert(data)

file.add(data)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which mode is used to open a file for appending data to the end?

'r'

'w'

'a'

'x'

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?

Similar Resources on Wayground