A network administrator writes a program to calculate and print the total data transferred (in TB) by Storage Rack 4 over 12 drive bays (represented by indices 0 to 11) from a 2D array called storageLog.
totalData = 0
totalData = totalData + storageLog[4, 0]
totalData = totalData + storageLog[4, 1]
totalData = totalData + storageLog[4, 2]
totalData = totalData + storageLog[4, 3]
totalData = totalData + storageLog[4, 4]
totalData = totalData + storageLog[4, 5]
totalData = totalData + storageLog[4, 6]
totalData = totalData + storageLog[4, 7]
totalData = totalData + storageLog[4, 8]
totalData = totalData + storageLog[4, 9]
totalData = totalData + storageLog[4, 10]
totalData = totalData + storageLog[4, 11]
print(totalData)
Refine the program to make it more efficient by using a loop. Write the refined version of the algorithm.
You must use either:
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.