Back to Handling Computer Files

Oak National Academy

Lessons written by expert teachers in England, each with slides, a video and quizzes.

Their topic:
Cyber threats and security · Programming: dictionaries and data files
For your topic:
Handling Computer Files · Computer Studies

Use these lessons alongside our lesson note, which covers your syllabus in full.

What this covers in your syllabus

3 lessons from Oak National Academy

Lesson 1 of 3 · GCSE level, ages 14 to 16

Malware: malicious software

By the end: I can describe malware and explain how it attacks systems.

Key learning points

  1. Malware is malicious software designed to harm, steal, or disrupt computer systems.
  2. There are different types of malware, including viruses, worms, trojans, ransomware, spyware, and adware.
  3. Each type of malware works differently, but they often trick users into downloading or installing them.
  4. Malware can cause serious damage, such as data loss, system failure or financial loss.

Keywords

malware
malicious software - a program designed to cause damage to computer systems, corrupt or change files, steal data or cause disruption to services
infect
to spread something harmful like a virus or malware into a system
stealing
the act of taking something that doesn’t belong to you, without permission and with no intention of giving it back
ransom
the money cybercriminals demand after locking files or systems

A common mistake

Mistake: Malware only affects computers, not phones or tablets.

In fact: Malware can infect any idevice that is connected to the internet, including smartphones, tablets and smart TVs. Mobile malware is increasingly common and can steal data, track location or lock users out of their devices — just like on computers.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is the main goal of ransomware?
How does spyware affect a user?
What does a trojan malware disguise itself as?
What is the difference between a virus and a worm?
Which of the following statements about malware is True?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 2 of 3 · GCSE level, ages 14 to 16

Reading text files

By the end: I can open and read data from a text file in a program.

Key learning points

  1. A file is a term used to describe data that is held in storage on a computer.
  2. File-handling is a term used to describe how programs work with the files that are stored in a computer.
  3. Different file-handling modes allow you to perform different operations on the contents of a file.
  4. Saving program data to an external file allows the data to be reused when the program runs again.

Keywords

file
a collection of data stored digitally, identified by a name
file-handling
an operation that is specified within a command to open a file, that determines how a file can be used
strip()
a Python method which removes any leading and trailing whitespaces or characters that you specify

A common mistake

Mistake: A text file can be stored anywhere to be used in a program using just the file name.

In fact: A text file must be stored in the same location as a program to be used to be accessed by file name alone. If it is stored elsewhere, the full path of the file will also need to be included.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

Opening a file in write (w) mode will...
Which of the following correctly opens a file named "data.txt" in read mode?
Which method reads an entire file and returns it as a string?
Using `readline()` will...

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 3 of 3 · GCSE level, ages 14 to 16

Writing to text files

By the end: I can write data to a new file and append data to an existing text file.

Key learning points

  1. There are different modes for opening a file, r (read), w (write) and a (append).
  2. When you open a file in write mode, it creates a new file. If the file already exists then the file will be overwritten.
  3. When you open a file and write to a file in append mode, it will add to the existing contents of the file.
  4. It is good practice to close the file once written to. Some IDEs will not write to a file until it is closed.

Keywords

write
a file handling mode that allows a program to write data to a file, where, if the file does not exist, a new file is created, and if the file already exists, the content is overwritten
append()
a file handling mode that allows a program to write extra data at the end of a file without erasing the existing contents of the file
overwrite
to replace information in (a computer file) with new information

A common mistake

Mistake: You have to create a new write() line for each line you want to add to a file.

In fact: You can write mutiple lines in one write() statement. But if you want the text to appear on separate lines, you must use the new line character.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What happens when you open a file in write ("w") mode?
What will the following code do? ```file = open("example.txt", "w") file.write("Hello, world!") file.close()```
Which of the following is the correct way to open a file, write text to it, and close it properly in Python?
Which character is used to ensure text is added to a new line in a file?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

The wording comes from each publisher. The layout and the links to your syllabus are ours.