Search Header Logo
file_handling_BN23

file_handling_BN23

Assessment

Presentation

Computers

9th - 12th Grade

Practice Problem

Medium

Created by

Brian New

Used 2+ times

FREE Resource

10 Slides • 10 Questions

1

File Handling

media

CS

2

goals

​O I can accurately describe how to handle a file

O I can write python code to read and write data to a file

3

Open Ended

When file handling, an endOfFile() command is very important.

Describe what this is as best you can.

4

endOfFile()

The endOfFile() command simply returns True or False as to whether we have reached the last line (or end) of a file. It allows code to detect when to stop reading from a file -- there is no more data to read.

5

Multiple Choice

endOfFile() returns what?

1

a string

2

an integer

3

a boolean

4

the last line

6

Multiple Choice

endOfFile(), if returning True, means that we can keep reading data from a file...

1

No, because we have now arrived at the end of the file.

2

Yes, because there will be room at the end of the file to read more.

7

Multiple Choice

Why would we need to use endOfFile() in code?

1

To prepare a file for new data.

2

To stamp the end of data with an 'end point'.

3

To close a file for safety.

4

To detect when a loop needs to stop reading from a file.

8

goals

​O I can accurately describe how to handle a file

O I can write python code to read and write data to a file

9

Open Ended

Question image

Now briefly describe everything you know about what the endOfFile() command is and what it is used for.

Bonus points for making your answer sound like it was written by a very angry wizard.

10

media

follow the link

add a new text file and write your own conversation

11

media

Why don't we need to use the endOfFile() command in this code?

12

Open Ended

Question image

# Write 4 brief, one-line comments that would help someone undertand the file handling parts of this code.

# At the start of each comment, specify which line the comment is about.

E.g. # (3) This imports the time module so that we can use the sleep() procedure.

13

goals

​O I can accurately describe how to handle a file

O I can write python code to read and write data to a file

14

Fill in the Blank

Files can be opened in two modes: 'r' for read and 'w' for _____

15

Fill in the Blank

Writing to a file means that d___ will be added or changed in that file.

16

Fill in the Blank

It is important to _____ a file after the code has finished using it (reading or writing).

17

Draw

Draw an image to express why a file should be 'closed' after we have used it.

18

media

​copy this code into a new project

​can you work out how to format the 'characters' text file? Create a new text file that would work with this program.

19

file handling in python

more file handling operations

20

goals

​O I can accurately describe how to handle a file

O I can write python code to read and write data to a file

File Handling

media

CS

Show answer

Auto Play

Slide 1 / 20

SLIDE