File Handling
File Handling
There are 3 tasks that you must complete, the tasks are differentiated by grade. Ensure you look at the marks when completing
the tasks. If you are struggling, use the OCR Exam reference guide to help you: https://www.ocr.org.uk/Images/558027-
specification-gcse-computer-science-j277.pdf
Once completed, try this on Python (You can either create an account using repl.it or if you have it downloaded use the IDE).
Please note, it may not be written in the same way as the reference language so you will need to read through the following
website to help you: http://computing.outwood.com/NEA/python/key-syntax.html identify the correct statements.
Python
Scenario: Create a text file (notepad) that contains the following text and save it as Bill.txt:
William Henry Gates III (born October 28, 1955) is an American business magnate, software developer, investor, author,
and philanthropist. He is the co-founder of Microsoft Corporation. During his career at Microsoft, Gates held the positions
of chairman, chief executive officer (CEO), president and chief software architect, while also being the largest
individual shareholder until May 2014.[6] He is considered one of the best known entrepreneurs of the microcomputer
revolution of the 1970s and 1980s.
Using exam reference language read the text file until it reaches the end. Once it has reached the end it will ask for an input
stating ‘What is this file about?’, if the answer given is Bill Gates (upper or lowercase), the output will be ‘Great! You
were paying attention’, otherwise it will say ‘Oh dear! I think you need to read it again!’.
Python
Scenario: A library gives a book code made from the first three letters of the book title in Upper Case, followed by the last
two digits of the year the book was published.
For example, “Poetry from the War”, published in 2012 would be given the code POE12. The library needs to store the
details for 100 new books in a text file named newBook.txt.
Using Exam Reference write a program that will ask the end user to input the book title and year it was published 100 times.
It will store this in the text file newBook.txt. Once completed, code this in Python and screenshot the outcome here.
Python