Constructs

EasyMediumHard
123456789101112131415161718192021222324252627282930
Question 18
Medium

A telemetry system is designed to decode channel indices entered by a technician into their uppercase alphabetic beacon identifiers. Only channel indices from 15 to 40 are valid.

Adding 50 to the channel index and then applying the function chr() generates the equivalent ASCII code for an uppercase letter.

The table shows accurate test data for a functional program.

InputOutput
14Invalid input
1515 maps to A
3030 maps to P
4040 maps to Z
41Invalid input

Below is the unfinished code for the program:

# telemetry.py
# Enter your code below

Amend the code to:

  • create an integer variable named shiftVal and set it to 0
  • take the input from the user and convert it to an integer (storing it in shiftVal)
  • check that the inputted number is between 15 and 40 inclusive
  • add 50 to the variable shiftVal and assign the result to the variable codePoint
  • join strings together with concatenation to display the message matching the test data table (e.g., "15 maps to A")
  • display the error message "Invalid input" if the entered number is outside the valid range.

Do not add any additional functionality.

[10]

Constructs Questions

  1. GCSE
  2. /Computer Science
  3. /Constructs