Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Additional Programming Techniques

ASCII Conversion

The use of basic string manipulation: ASCII Conversion

2.2.3 Additional Programming Techniques

Practise exam questions

Additional Programming Techniques — Note 13 of 13

What you need to know

ASCII conversion means changing a character into its character code, or a code back into its character. In OCR Exam Reference Language, ASC() takes a character and returns its ASCII code, and CHR() takes a code and returns the character. Because the codes for letters are in order, you can do arithmetic on them, for example to move a letter along the alphabet or change its case.

What to know

  • ASC(character) returns a NUMBER: ASC("A") gives 65.
  • CHR(code) returns a CHARACTER: CHR(97) gives "a".
  • Letter codes are in alphabetical order, so adding 1 to a code gives the next letter: CHR(ASC("g") + 1) gives "h".
  • Each lower-case letter's code is 32 more than its upper-case letter's code. Subtract 32 to change lower case to upper case, and add 32 to go the other way.
  • To shift an UPPER-CASE letter along the alphabet (by 26 places or fewer), add the shift to its code. If the new code is more than 90 (ASC("Z")), subtract 26 so it wraps back round to the start of the alphabet.
  • To process a whole string, loop over it one character at a time with .substring(i, 1), convert each character, and join the results onto a new string with +.
  • In Python, ASC() is ord() and CHR() is chr(): ord("A") gives 65 and chr(97) gives 'a'.

Code examples

ASCII conversion (OCR Exam Reference Language)
text
print(ASC("A"))              // 65
print(CHR(97))               // a

// Codes are in order: add 1 for the next letter
letter = "g"
print(CHR(ASC(letter) + 1))  // h

// Change a lower-case word to upper case, one character at a time
word = "lemon"
upperWord = ""
for i = 0 to word.length - 1
    code = ASC(word.substring(i, 1))
    upperWord = upperWord + CHR(code - 32)
next i
print(upperWord)             // LEMON
ASCII conversion in Python
python
print(ord("A"))              # 65
print(chr(97))               # a

# Codes are in order: add 1 for the next letter
letter = "g"
print(chr(ord(letter) + 1))  # h

# Change a lower-case word to upper case, one character at a time
word = "lemon"
upper_word = ""
for i in range(len(word)):
    code = ord(word[i])
    upper_word = upper_word + chr(code - 32)
print(upper_word)            # LEMON

Key terms

ASCII conversion

Changing a character into its numeric ASCII code, or changing a code back into the character it represents.

Character code

The number a character set such as ASCII uses to represent a character. 'A' is 65 and 'a' is 97.

Exam technique

  • Tip:When a loop processes every character, run it from 0 to .length - 1 and use the loop counter as the start position in .substring(counter, 1). Examiners found the substring position and the number added to each code were most often wrong.
  • Mistake:Mixing up the two functions. ASC turns a character into a NUMBER; CHR turns a number into a CHARACTER. To join the result of ASC onto a string, cast it with str() first.
  • Example:To change a lower-case letter in letter to upper case: upper = CHR(ASC(letter) - 32). With letter = "g": ASC("g") is 103, 103 − 32 = 71, and CHR(71) is "G".

Ready to test yourself?

Practise 2.2.3 questions
← Previous noteRandom number generation2.2.3 Additional Programming TechniquesNext topic →Anticipating misuse, Authentication2.3.1 Defensive Design

Back to Additional Programming Techniques

Revise another OCR GCSE topic: Programming Fundamentals

Additional Programming Techniques

Note 13 of 13

  1. 1Concatenation
  2. 2slicing
  3. 3ASCII Conversion
  4. 4Open, Read, Write, Close
  5. 5Records to store data
  6. 6SQL to search for data
  7. 7one-dimensional (1D)
  8. 8two-dimensional arrays(2D)
  9. 9Sub programs (functions and procedures) to produce structured code
  10. 10local variables
  11. 11global variables
  12. 12arrays
  13. 13Random number generation
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).