Skip to content

Course home

String handling operations in a programming language

String handling operations in a programming language

EasyMedium
1234567891011121314151617181920
Question 15

A marine biologist wants to create unique tracking codes for marine specimens in a research database.

Table 1

specimenIDspecieslocation
M401DOLPHINPACIFIC
M402TURTLEATLANTIC
M403OCTOPUSINDIAN

A tracking code is made up of the:

  • specimenID
  • first letter and the second letter of the species
  • first letter of the location

For example:

  • the tracking code for DOLPHIN would be M401DOP
  • the tracking code for TURTLE would be M402TUA

Write a Python program to generate the tracking code for a specimen.

The program should:

  • get the user to enter the specimenID, species and location
  • create the tracking code
  • assign the tracking code to a variable called trackingCode

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