Exam Q1 Practice – June 2022

Suggested time: 15 minutes

A program is required to convert numbers entered by the user to their alphabetic equivalent. Only
numbers from 5 to 30 are valid.

Adding 60 to the number 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.
4 – invalid input
5 – 5 is equal to A
22 – 22 is equal to R
30 – 30 is equal to Z
31 – invalid input

Amend the code to:

• create an integer variable named num and set it to 0
• take the input from the user and convert it to an integer
• check that the inputted number is between 5 and 30
• add 60 to the variable num and assign the result to the variable decimalCode
• join strings together with concatenation
• display an error message.
Do not add any additional functionality.

Scroll to Top