Converting a word to ASCII decimal codes

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Converting a word to ASCII decimal codes

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which list gives the ASCII decimal codes for the word "Hi"?
A 105 72
B 72 105
2. Which statement about the letters A and a is true in ASCII?
A A is 65 and a is 97
B A and a are both 65
3. Which list gives the ASCII decimal codes for the name "Mia"?
A 109 105 97
B 77 105 97
4. How many ASCII codes do you write for the word "Jack"?
A 4 codes, one for each character
B 1 code for the whole word
5. Which list gives the ASCII decimal codes for "Cat"?
A 67 97 116
B 99 97 116

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Sam = 83 97 109 ALeo = 76 101 111
2A = 65, a = 97 BThe capital A was given the lowercase code. Capital A is 65, so the answer should be 65 118 97.
3Write the ASCII code for each letter in the same order as the letters in the word, checking each character once CA capital letter and its lowercase letter have different ASCII codes, so they must be kept separate
4The same letter has two different codes depending on whether it is a capital or lowercase DThe codes are in the wrong order. The word is M, i, a, so the codes should be 77 105 97.
5Mia = 77 97 105 EM = 77, m = 109
6Ava = 97 118 97 FS is 83, a is 97 and m is 109, written in the same order as the letters in the word

Definitions

ASCII decimal code

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
=____("H")
2.
Hi = H is 72, i is ___
3.
A is 65, so a is __
4.
FOR EACH letter __ "Sam" OUTPUT CODE(letter) END FOR
5.
=CODE(MID(A1,_,1))

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A word = "Hi"
B H = 73
C i = 105
D codes = 72 105
Question 2
A word = "Cat
B C = 67
C a = 97
D t = 116
Question 3
A for ch in "Zoe"
B print(ord(ch))
C # Z = 90, o = 111, e = 101
Question 4
A word: Ava
B A = 65
C v = 118
D a = 65
E codes: 65 118 97
Question 5
A name = "Leo"
B for ch in len(name):
C print(ord(ch))

Answer Key

Converting a word to ASCII decimal codes
Section A: Quick Questions
Q1
B — 72 105
Q2
A — A is 65 and a is 97
Q3
B — 77 105 97
Q4
A — 4 codes, one for each character
Q5
A — 67 97 116
Section B: Match the Pairs
Q1
Sam = 83 97 109 → S is 83, a is 97 and m is 109, written in the same order as the letters in the word
Q2
A = 65, a = 97 → A capital letter and its lowercase letter have different ASCII codes, so they must be kept separate
Q3
Write the ASCII code for each letter in the same order as the letters in the word, checking each character once → Leo = 76 101 111
Q4
The same letter has two different codes depending on whether it is a capital or lowercase → M = 77, m = 109
Q5
Mia = 77 97 105 → The codes are in the wrong order. The word is M, i, a, so the codes should be 77 105 97.
Q6
Ava = 97 118 97 → The capital A was given the lowercase code. Capital A is 65, so the answer should be 65 118 97.
Section C: Definitions
Q1
ASCII decimal code — Look up each character in the ASCII table and write its decimal number in order. Capitals and lowercase differ, so Hi is 72 105 (H is 72, i is 105).
Section D: Fill in the Blanks
Q1
=CODE("H")
Q2
Hi = H is 72, i is 105
Q3
A is 65, so a is 97
Q4
FOR EACH letter IN "Sam" OUTPUT CODE(letter) END FOR
Q5
=CODE(MID(A1,2,1))
Section E: Spot the Error
Q1
B — Capital H is 72 in the ASCII table. 73 is capital I. The line should be H = 72.
Q2
A — The string is missing its closing quote. It should be word = "Cat".
Q3
A — A for loop line must end with a colon. It should be for ch in "Zoe":
Q4
D — Lowercase a is 97. 65 is capital A. Capitals and lowercase have different codes, so it should be a = 97.
Q5
B — len(name) gives a number (3), which can't be looped over to check each character. It should be for ch in name:.