if line[0] > 50 then
file = open(“numbers.txt”)
line = file.readLine()
print(“Large number”)
endif
file.close()
while NOT file.endOfFile()
endwhile
File Handling Activity - Task 1
Below is pseudocode that should read the information from the file shown. If the piece of number read is greater than 50 then it should print “Large Number”, otherwise it should ignore that data.
You need to rearrange the pseudocode so it is in the correct order.
file.close()
username = input(“Enter username: ”)
file = open(“usernames.txt”)
name = input(“Enter your name: ”)
password = input(“Enter password: ”)
file.writeLine(username + “,” + password + “,” + name)
File Handling Activity Task 2
Below is the pseudocode that should write the username, password, and name of the user to a file called usernames.txt. Organise the pseudocode into the correct order.
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
file = open(“image.txt”)
file.writeLine(0000000000000)
file.writeLine(0001000001000)
File Handling Activity Task 3
Below is an image that is made up of black and white pixels. You need to finish writing this program that writes the image to a file. 1 represents black and 0 represents white.