4.2.1.3 Fields, records and files Flashcards Preview

Computing Theory > 4.2.1.3 Fields, records and files > Flashcards

Flashcards in 4.2.1.3 Fields, records and files Deck (4)
Loading flashcards...
1
Q

What is a text file?

A

A sequence of characters organised on a line by line basis. It can only contain characters, whereas a non-text file could store images, sounds etc.

2
Q

What’s the difference between how data is stored in a text file and a binary file?

A

In text files all data is stored as characters, binary files store different data types. Text files store data so that they could be opened or created in a text editor, whereas it’s much more difficult to edit binary files.

3
Q

How do you read a text file in python?

A

file = open(“filename.txt”, “r”)
for line in file:
array.append(line.strip())
file.close()

4
Q

How do you write to a text file in python?

A

File = open(“filename.txt”, “w”)
File.write(“string”)
File.close()

Decks in Computing Theory Class (102):