Skip to content

Course home

String handling operations in a programming language

String handling operations in a programming language

EasyMedium
1234567891011121314151617181920
Question 13

A librarian wants to create shelf codes for each book in a library archive.

Table 1 shows some of the books.

Table 1

bookIDtitleauthor
B1DRACULASTOKER
B2FRANKENSTEINSHELLEY
B3MACBETHSHAKESPEARE

A shelf code is made up of the:

  • bookID
  • first letter and the second letter of the title
  • first letter of the author's surname

For example:

  • the shelf code for DRACULA would be B1DRS
  • the shelf code for FRANKENSTEIN would be B2FRS

Write a Python program to generate the shelf code for a book.

The program should:

  • get the user to enter the bookID, title and author
  • create the shelf code
  • assign the shelf code to a variable called shelfCode

You should use indentation as appropriate, meaningful variable name(s), and valid Python syntax in your answer.

[4]
Markscheme

String handling operations in a programming language Questions

  1. GCSE
  2. /Computer Science
  3. /String handling operations in a programming language

89 exam-style questions on AQA GCSE Computer Science String handling operations in a programming language. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank