IGCSE Computer Science 0478 — 8.3 File Handling Hangman
Years 10–11 · IGCSE · 19 key terms.
Every word, shuffled.
The names stay in this browser on this computer — they are never sent to Cloodit. A random student is called for each word.
Saving data so it survives after the program closes. See the whole journey →
Want your own words? Free Hangman Generator →
Same words, on paper
The quiet activity after the loud one. Free to print, answer keys included.
Crossword8.3 File Handling · 8.2 Arrays and 8.3 File Handling · 8.3 File Handling and 9 Databases · all 4
Word search8.2 Arrays and 8.3 File Handling · 8.3 File Handling and 9 Databases · 8.1c Procedures and Functions and 8.2 Arrays
Worksheetfor any module, with answer key
When your class is on devices — Snake Break and Diamond Dash run on the same modules, with a free class.
The 19 key terms
- 1file
- A file keeps data on storage so it still exists after the program closes, unlike variables. The program can read it back next time it runs, such as a saved high score or a list of names.
- 2"FileA.txt"
- A file identifier is the name of the file, written as a string in double quotes with its extension, such as "FileA.txt". The same identifier is used in every file command.
- 3file mode
- States what a program will do with an open file: READ gets data out of it, WRITE puts data into it. A file is open in only one mode at a time, chosen by what the program needs.
- 4DECLARE LineOfText : STRING
- Creates a variable named LineOfText that holds text. Declare it before the file commands that use it, for example before READFILE stores a line in it.
- 5OPENFILE "Scores.txt" FOR WRITE
- Opens the file Scores.txt in write mode so data can be written into it with WRITEFILE. The file must be opened before writing. Keywords are in capitals.
- 7WRITEFILE "Scores.txt", Score
- Writes the value stored in a variable into an open file. Give the file name, a comma, then the variable. The file must already be open in WRITE mode.
- 8WRITEFILE "Names.txt", LineOfText
- Writes the text held in the STRING variable LineOfText into the file Names.txt as one new line. Each WRITEFILE adds one more line to the file.
- 9CLOSEFILE "Scores.txt"
- Closes the file named in the identifier once you have finished reading or writing, so data is saved and the file is released. The name must match the one used in OPENFILE.
- 10CLOSEFILE
- Closes an open file so its data is safely saved and the file can be opened again in a different mode, such as READ after WRITE. Use one CLOSEFILE for each OPENFILE.
- 11OPENFILE "Scores.txt" FOR READ
- Opens the existing file Scores.txt in READ mode so the program can read data from it with READFILE. The file must already exist, and READ mode does not change its contents.
- 12READFILE "Scores.txt", Score
- Reads one data item from the open file and stores it in the variable. The file must already be open in READ mode, and the variable's data type must match the item.
- 13READFILE "Names.txt", LineOfText
- Reads the next line of text from the open file Names.txt into the STRING variable LineOfText. Each READFILE call reads the following line. Declare the variable first.
- 15FOR Index ← 1 TO 30
- A count-controlled loop. It repeats the indented statements once for each value of Index, from 1 up to 30, going up by 1 each time. NEXT Index closes the loop.
- 16FOR Count ← 1 TO 5
- A FOR loop with INPUT and WRITEFILE inside repeats a fixed number of times, writing one item to the open file on each repeat. CLOSEFILE goes after NEXT.
- 18WRITE, CLOSEFILE, READ
- Open a file for WRITE, store data with WRITEFILE, then CLOSEFILE. Reopen the same file name for READ and READFILE gets the data back to use again.
- 19WRITEFILE FileB.txt, LineOfText
- Writes the line held in LineOfText (read earlier from FileA.txt) into FileB.txt, copying it between files. Both files must be opened first and each one closed after.
- 20trace table
- A table that follows a program step by step, recording the file contents and each variable's value after every file command, until you find the final OUTPUT.
- 21file handling error
- A mistake such as using the wrong mode, missing OPENFILE or CLOSEFILE, using different file names, or opening a file FOR WRITE and wiping its old data.
- 22DECLARE, OPENFILE, WRITEFILE, CLOSEFILE
- The order of a complete file program: declare variables, open the file in the right mode, read or write the data, then close the file. Keywords are in capitals and statements are indented.
Frequently Asked Questions
Do I need an account?
No. Hangman runs straight from this page — no account, no sign-up, nothing to install. If you add your class names, they are saved in your own browser and never sent to Cloodit.
How do I play it with my class?
Put the page on your whiteboard or projector and press Play. The class calls out letters and you click or type them. Six wrong letters and the word gets away. After every word its definition appears, so each round ends on the meaning, not just the spelling.
Can I use my own words?
Yes. The free Hangman generator at cloodit.com/hangman/ takes any list: one word or phrase per line, with a definition after a dash if you want it shown at the end of the round.
Can I put my students' names in?
Yes. Add your class list and a random student is called for each word. The list stays in this browser on this computer, so it is still there next lesson.
Are the worksheets free too?
Yes. Every module in this journey has a free printable worksheet with a full answer key, and there are crosswords and word searches built from the same key terms.