The ASCII code (Pronounced ask-ee) is a code for representing English characters as numbers, with each character assigned a number from 0 to 127. For example, the ASCII code for uppercase A is 65. The extended ASCII contains 256 characters (using numbers from 0 to 255).
To see a list of the most useful ASCII codes you can download our simplified ASCII helpsheet.
Each character that appear on your keyboard has a unique value. This includes 26 lowercase letters & 26 uppercase letters of the alphabet, the number digits from 0 to 9 and a range of punctuation signs and special characters.
chr() and ord() functions
Using Python you can easily access ASCII values of a character using the ord() function. For instance ord(“A”) returns 65 and chr(65) returns “A”.
The following Python code is a quiz based game. The user tries to guess the ASCII value of different characters randomly selected. The difference between the user’s guess and the actual ascii value of the character being displayed is used to decrement a life score.
The user starts the game with a life score of 255 and tries to guess as many ASCII values as possible before reaching a life score of 0.