UCASE: converting to upper case

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

UCASE: converting to upper case

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does UCASE("Happy") return?
A "Happy"
B "HAPPY"
2. Which line stores the upper case version of Name in a variable called Shout?
A Shout ← UCASE(Name)
B UCASE(Name) → Shout
3. Name is "zoe". After the line X ← UCASE(Name) what is the value of Name?
A "zoe"
B "ZOE"
4. Which line changes the variable Name itself to upper case?
A Name ← UCASE(Name)
B UCASE(Name)
5. Letter is a CHAR holding 'q'. Can UCASE be used on it?
A No, UCASE only works on STRING
B Yes, UCASE('q') returns 'Q'

Match the Pairs

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

Left columnRight column
1UCASE("Happy") AIF UCASE(Answer) = "YES" THEN
2Initial ← UCASE('q') BStores the CHAR 'Q' in Initial because UCASE also works on a single CHAR
3UCASE does not change the original variable unless you assign the result back to it CName ← UCASE(Name)
4UCASE makes comparing text fair, because both sides are converted to the same case DIf the user types yes or Yes, the comparison fails because the case differs. Use UCASE(Answer) = "YES" to compare fairly.
5UCASE(Name) OUTPUT Name EThe result of UCASE is thrown away, so Name is unchanged and the output is still the original text. Assign it: Name ← UCASE(Name)
6IF Answer = "YES" THEN FReturns the text "HAPPY" with every letter changed to upper case

Definitions

UCASE(x)

Fill in the Blanks

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

1.
OUTPUT _____("Happy")
2.
Word _ UCASE(Word)
3.
DECLARE Letter : CHAR Letter ← 'q' OUTPUT UCASE(______)
4.
IF _____(Answer) = "YES" THEN OUTPUT "Correct" ENDIF
5.
Word ← "Happy" Big ← UCASE(Word) OUTPUT ____

Spot the Error

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

Question 1
A DECLARE word : STRING
B word ← "Happy"
C OUTPUT UPPER(word)
Question 2
A DECLARE name : STRING
B INPUT name
C name ← UCASE(name)
D OUTPUT "name"
Question 3
A DECLARE letter : INTEGER
B letter ← 'q'
C OUTPUT UCASE(letter)
Question 4
A DECLARE reply STRING
B INPUT reply
C IF UCASE(reply) = "YES" THEN
D OUTPUT "Agreed"
E ENDIF
Question 5
A DECLARE tag : STRING
B tag ← "go"
C OUTPUT tag
D OUTPUT UCASE tag

Answer Key

UCASE: converting to upper case
Section A: Quick Questions
Q1
B — "HAPPY"
Q2
A — Shout ← UCASE(Name)
Q3
A — "zoe"
Q4
A — Name ← UCASE(Name)
Q5
B — Yes, UCASE('q') returns 'Q'
Section B: Match the Pairs
Q1
UCASE("Happy") → Returns the text "HAPPY" with every letter changed to upper case
Q2
Initial ← UCASE('q') → Stores the CHAR 'Q' in Initial because UCASE also works on a single CHAR
Q3
UCASE does not change the original variable unless you assign the result back to it → Name ← UCASE(Name)
Q4
UCASE makes comparing text fair, because both sides are converted to the same case → IF UCASE(Answer) = "YES" THEN
Q5
UCASE(Name) OUTPUT Name → The result of UCASE is thrown away, so Name is unchanged and the output is still the original text. Assign it: Name ← UCASE(Name)
Q6
IF Answer = "YES" THEN → If the user types yes or Yes, the comparison fails because the case differs. Use UCASE(Answer) = "YES" to compare fairly.
Section C: Definitions
Q1
UCASE(x) — UCASE(x) returns the string or CHAR x with every letter in upper case. UCASE("Happy") returns "HAPPY". The original variable only changes if you assign the result.
Section D: Fill in the Blanks
Q1
OUTPUT UCASE("Happy")
Q2
Word ← UCASE(Word)
Q3
DECLARE Letter : CHAR Letter ← 'q' OUTPUT UCASE(Letter)
Q4
IF UCASE(Answer) = "YES" THEN OUTPUT "Correct" ENDIF
Q5
Word ← "Happy" Big ← UCASE(Word) OUTPUT Word
Section E: Spot the Error
Q1
C — The Cambridge pseudocode function is UCASE, not UPPER. The line should be OUTPUT UCASE(word).
Q2
D — The quotes make this the text "name" instead of the variable. It should be OUTPUT name so the upper case value is shown.
Q3
A — The variable stores a single character, so it must be declared as CHAR. An INTEGER cannot hold 'q'.
Q4
A — A DECLARE statement needs a colon between the identifier and the data type. It should be DECLARE reply : STRING.
Q5
D — UCASE is a function, so its argument must be inside brackets. It should be OUTPUT UCASE(tag).