Question bank › GCSE Computer Science › Programming fundamentals

String manipulation and file handling

Answer on paper first, then reveal the mark scheme one mark at a time.

1Grade 4–54 marks

The variable word holds the string "Football". State the output of each line.

print(word.length)
print(word.subString(4, 3))
print(word.upper)
print(word.left(3))

[4]

2Grade 6–74 marks

A text file called scores.txt contains one player's name and score on each line.

Write code that opens the file, outputs every line in the file, then closes the file. Use OCR Exam Reference Language or a high-level programming language. [4]

Still losing marks on this topic?

Book a free introductory session and we'll find exactly which step is costing you.

Book a free intro