File Handling
Lesson Instructions
Watch and follow the YouTube video, the lesson contains three parts:
Key Information and content - all you need to do here is watch and listen. We recommend you take some notes for this one!
Learning activity - You are to complete the activity, by completing the sorting activities on file handling and then using this to write your own.
Consolidation - these are past exam question and are for deliberate practice to check your understanding.
Task - File Handling Activity
Task - Exam Questions - Deliberate Practice
Mark Scheme
Question 1
1 mark per bullet
Inputs for firstname, last name and age
Correctly uses substring to get first two letters of the first name
Correct concatenation of the username
Open usernames.txt
Writes the input information and username to file
Closes the file
Note, pseudocode shown below is an example – candidates may answer very differently, but award marks if intention can be seen.
firstname = input(“Enter firstname”)
lastname = input(“Enter lastname”)
age = input(“Enter age”)
username = firstname.substring(0,2) + lastname + age
file = open(“username.txt”)
file.writeLine(firstname + “,” + lastname + “,” + age + “,” + username)
file.close()