Python Files Class XII

Python Files Class XII

12th Grade

26 Qs

quiz-placeholder

Similar activities

IC3 gs5 Spark

IC3 gs5 Spark

6th - 12th Grade

26 Qs

Работа со строками  Python

Работа со строками Python

9th - 12th Grade

23 Qs

Photoshop Learn #1

Photoshop Learn #1

9th - 12th Grade

21 Qs

Ulangan Harian TIK Kelas 5

Ulangan Harian TIK Kelas 5

5th Grade - University

30 Qs

IT Essentials Ch 12 Review - Mobile, Linux, and MacOS

IT Essentials Ch 12 Review - Mobile, Linux, and MacOS

9th Grade - Professional Development

22 Qs

latihan fun

latihan fun

12th Grade

24 Qs

ASAS SAINS KOMPUTER

ASAS SAINS KOMPUTER

12th Grade

25 Qs

Pengolah Kata - Dasar

Pengolah Kata - Dasar

12th Grade

25 Qs

Python Files Class XII

Python Files Class XII

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Pravin S R

Used 30+ times

FREE Resource

26 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 single string?

.read()

.readline()

.readlines()

.read(all)

4.

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)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the best way to read the first line of a file?

.read()

.readline()

.readlines()

.read(all)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

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

\n

#

@

»

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

This command will open MyFile = open('MyText.txt', 'r')

To read the file

To append to the file

To write to the file

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?